import '../lookup.dart'; import 'gas_refill_details.dart'; class GasRefillModel { int? id; String? userId; String? clientName; String? title; Lookup? status; List? details; GasRefillModel({ this.id, this.userId, this.clientName, this.title, this.status, this.details, }); bool validate() { if (title == null) return false; if (status == null) return false; if (details == null && (details?.isEmpty ?? true)) return false; return true; } fromGasRefillModel(GasRefillModel model) { id = model.id; userId = model.userId; clientName = model.clientName; title = model.title; status = model.status != null ? Lookup.fromStatus(model.status!) : null; details = model.details?.map((e) => GasRefillDetails.fromDetails(e)).toList(); } factory GasRefillModel.fromJson(Map parsedJson) { List details = []; if (parsedJson["gazRefillDetails"] != null) { List list = parsedJson["gazRefillDetails"]; details = list.map((e) => GasRefillDetails.fromJson(e)).toList(); } return GasRefillModel( id: parsedJson["id"], userId: parsedJson["uid"], title: parsedJson["title"], clientName: parsedJson["site"]['custName'], status: Lookup.fromJson(parsedJson["status"]), details: details, ); } }