import 'package:barcode_scan/barcode_scan.dart';

Future<String> scanBarcode() async {
  try {
    String barcode = await BarcodeScanner.scan();
    if (barcode == null) return null;

    String gs = String.fromCharCode(29);
    if (barcode.contains(gs)) {
      var codes = barcode.split(gs);
      barcode = codes.length >= 2 ? codes[1] : barcode;
    }
    return barcode;
  } catch (e) {
    print('error: $e');
    return null;
  }
}
