BarcodeResult.fromJson constructor
BarcodeResult.fromJson(
- Map json
Creates a BarcodeResult instance from a JSON object.
Implementation
factory BarcodeResult.fromJson(Map<dynamic, dynamic> json) {
String format = json['format'];
int x1 = json['x1'];
int y1 = json['y1'];
int x2 = json['x2'];
int y2 = json['y2'];
int x3 = json['x3'];
int y3 = json['y3'];
int x4 = json['x4'];
int y4 = json['y4'];
int angle = json['angle'];
// Convert barcode byte data
List<Object?> rawBytes = json['barcodeBytes'];
Uint8List barcodeBytes =
Uint8List.fromList(rawBytes.map((e) => e as int).toList());
String text = String.fromCharCodes(barcodeBytes);
return BarcodeResult(
format,
text,
x1,
y1,
x2,
y2,
x3,
y3,
x4,
y4,
angle,
barcodeBytes,
);
}