# startBarcodeScanner static method

Future<ResultWrapper<BarcodeScannerUiResult>> startBarcodeScanner(

1. MethodChannel channel,
2. BarcodeScannerScreenConfiguration config

)

## Implementation

    static Future<ResultWrapper<BarcodeScannerUiResult>> startBarcodeScanner(
      MethodChannel channel,
      BarcodeScannerScreenConfiguration config,
    ) async {
      try {
        final parameters = config.toJson();

        final formatter = isUsecaseSupportBarcodeFormatter(config)
            ? getBarcodeFormatter(config.useCase)
            : null;

        if (formatter != null) {
          _initBarcodeFormatterHandler(formatter);
          _barcodeFormatterCallbackChannel.setMethodCallHandler(_handler);
          parameters['shouldUseBarcodeFormatter'] = true;
        }

        final result =
            await channel.invokeMethod('startBarcodeScanner', parameters);

        _handler = null;

        return ResultWrapper.fromJson(
          jsonDecode(result),
          fromJsonT: BarcodeScannerUiResult.fromJson,
        );
      } on PlatformException catch (e) {
        Logger.root.severe(e);
        return ResultWrapper.error(e.message ?? 'Unknown platform error');
      } catch (e) {
        return ResultWrapper.error(e.toString());
      }
    }