ResponseModel.fromMap constructor

ResponseModel.fromMap(
  1. Map<String, dynamic> map
)

get ResponseModel from map.

Implementation

factory ResponseModel.fromMap(Map<String, dynamic> map) {
  final code = map['Response']['ResponseCode'];

  return ResponseModel(
    header: HeaderModel.fromMap(map['Header']),
    responseCode: code is int ? code : int.tryParse(code) ?? 0,
    responseMsg: map['Response']['ResponseMsg'] ?? '',
    scannedData: map['Detail']?['ScannedData'] ?? '',
    rawResponse: json.encode(map),
  );
}