setBarcodeFormats method

Future<int> setBarcodeFormats(
  1. int formats
)

Sets the barcode formats to be recognized.

The formats parameter specifies the barcode types to detect. Returns 0 on success, or an error code on failure.

Implementation

Future<int> setBarcodeFormats(int formats) async {
  try {
    dynamic settings =
        await handleThenable(_barcodeReader!.getSimplifiedSettings(""));
    Map obj = json.decode(stringify(settings));
    obj['barcodeSettings']['barcodeFormatIds'] = formats;
    await handleThenable(
        _barcodeReader!.updateSettings("", json.encode(obj)));
  } catch (e) {
    print(e);
    return -1;
  }
  return 0;
}