fromJson static method
Implementation
static BrotherDevice? fromJson(Map<String, String?> json) {
if ((json['modelName'] == null && json['printerName'] == null && json['bleAdvertiseLocalName'] == null) || json['source'] == null) {
return null;
}
final modelFound = _findModel(
json['modelName'],
json['printerName'],
json['bleAdvertiseLocalName'],
);
if (modelFound == null) {
return null;
}
final sourceFound = _findSource(json['source']!);
if (sourceFound == null) {
return null;
}
return BrotherDevice(
model: modelFound,
ipAddress: json['ipAddress'],
location: json['location'],
modelName: json['modelName'] ?? modelFound.nameAndroid,
printerName: json['printerName'],
serialNumber: json['serialNumber'],
nodeName: json['nodeName'],
macAddress: json['macAddress'],
bleAdvertiseLocalName: json['bleAdvertiseLocalName'],
source: sourceFound,
);
}