ScanModel.fromMap constructor
get ScanModel from map
.
Implementation
factory ScanModel.fromMap(Map<String, dynamic> map) {
final code = map['Response']['ResponseCode'];
final productCode = map['Detail']['ScannedData'];
// final List<Map<String, dynamic>> scannedProducts =
// List<Map<String, dynamic>>.from(map['Detail']['ScannedData']);
return ScanModel(
header: HeaderModel.fromMap(map['Header']),
responseCode: code is int ? code : int.tryParse(code) ?? 0,
responseMsg: map['Response']['ResponseMsg'] ?? '',
rawResponse: json.encode(map),
scannedProducts: [
ScanProductModel(
itemCount: 1,
itemValue: productCode.toString(),
),
],
);
}