Navaron Bracke

add a toBarcode getter to the rsult JS interop class

@@ -3,6 +3,8 @@ import 'dart:typed_data'; @@ -3,6 +3,8 @@ import 'dart:typed_data';
3 import 'dart:ui'; 3 import 'dart:ui';
4 4
5 import 'package:mobile_scanner/src/enums/barcode_format.dart'; 5 import 'package:mobile_scanner/src/enums/barcode_format.dart';
  6 +import 'package:mobile_scanner/src/enums/barcode_type.dart';
  7 +import 'package:mobile_scanner/src/objects/barcode.dart';
6 import 'package:mobile_scanner/src/web/zxing/result_point.dart'; 8 import 'package:mobile_scanner/src/web/zxing/result_point.dart';
7 9
8 /// The JS static interop class for the Result class in the ZXing library. 10 /// The JS static interop class for the Result class in the ZXing library.
@@ -109,4 +111,16 @@ extension ResultExt on Result { @@ -109,4 +111,16 @@ extension ResultExt on Result {
109 111
110 return timestamp?.toDartInt; 112 return timestamp?.toDartInt;
111 } 113 }
  114 +
  115 + /// Convert this result to a [Barcode].
  116 + Barcode get toBarcode {
  117 + return Barcode(
  118 + corners: resultPoints,
  119 + format: barcodeFormat,
  120 + displayValue: text,
  121 + rawBytes: rawBytes,
  122 + rawValue: text,
  123 + type: BarcodeType.text,
  124 + );
  125 + }
112 } 126 }