startCreditCardScanner static method

Starts the Credit Card Scanner UI with the provided config.

Returns a ResultWrapper containing a CreditCardScannerUiResult on success, or an error if the operation fails.

Implementation

static Future<ResultWrapper<CreditCardScannerUiResult>>
    startCreditCardScanner(
        CreditCardScannerScreenConfiguration config) async {
  try {
    var result = await ScanbotSdk.channel
        .invokeMethod('startCreditCardScanner', config.toJson());
    return ResultWrapper.fromJson(jsonDecode(result),
        fromJsonT: (data) =>
            CreditCardScannerUiResult.fromJson(data as Map<String, dynamic>));
  } on PlatformException catch (e) {
    Logger.root.severe(e);
    return ResultWrapper.error(e.message ?? 'Unknown platform error');
  } on Exception catch (e) {
    return ResultWrapper.error(e.toString());
  }
}