Printer.fromJson constructor
Create Printer from JSON with validation
Implementation
factory Printer.fromJson(Map<String, dynamic> json) {
try {
return Printer(
address: json['address'] as String?,
name: json['name'] as String?,
connectionType:
_getConnectionTypeFromString(json['connectionType'] as String?),
isConnected: json['isConnected'] as bool?,
vendorId: json['vendorId']?.toString(),
productId: json['productId']?.toString(),
);
} catch (e) {
throw FormatException('Invalid Printer JSON format: $e');
}
}