scanDocument method

  1. @override
Future<bool> scanDocument(
  1. DocumentScannerConfiguration scanConfig
)
override

Implementation

@override
Future<bool> scanDocument(DocumentScannerConfiguration scanConfig) {
  var dataToPass = <String, dynamic>{
    'allowCaptureModeSetting': scanConfig.allowCaptureModeSetting,
    'autoCapture': scanConfig.autoCapture,
    'defaultScanFilter': scanConfig.defaultScanFilter.value,
    'allowPageRotation': scanConfig.pageEditConfig.allowPageRotation,
    'allowPageFilter': scanConfig.pageEditConfig.allowPageFilter,
    'allowPageArrangement': scanConfig.pageEditConfig.allowPageArrangement,
    'allowPageCropping': scanConfig.pageEditConfig.allowPageCropping,
    'allowPageRetake': scanConfig.pageEditConfig.allowPageRetake,
    'pageArrangementShowDeleteButton':
        scanConfig.pageEditConfig.pageArrangementShowDeleteButton,
    'pageArrangementShowPageNumber':
        scanConfig.pageEditConfig.pageArrangementShowPageNumber,
    'onboardingImageSource': scanConfig.onboardingImageSource,
    'source': scanConfig.source.index,
    'sourceImages': scanConfig.sourceImages,
    'autoCrop': scanConfig.autoCrop,
    'multiPage': scanConfig.multiPage,
    'preCaptureFocus': scanConfig.preCaptureFocus,
    'colorPrimaryLight':
        scanConfig.colorConfig.colorPrimary?.item1.toARGB32(),
    'colorPrimaryDark': scanConfig.colorConfig.colorPrimary?.item2.toARGB32(),
    'colorSecondaryLight':
        scanConfig.colorConfig.colorSecondary?.item1.toARGB32(),
    'colorSecondaryDark':
        scanConfig.colorConfig.colorSecondary?.item2.toARGB32(),
    'colorOnSecondaryLight':
        scanConfig.colorConfig.colorOnSecondary?.item1.toARGB32(),
    'colorOnSecondaryDark':
        scanConfig.colorConfig.colorOnSecondary?.item2.toARGB32(),
    'colorScanButtonsLayoutBackgroundLight': scanConfig
        .colorConfig.colorScanButtonsLayoutBackground?.item1
        .toARGB32(),
    'colorScanButtonsLayoutBackgroundDark': scanConfig
        .colorConfig.colorScanButtonsLayoutBackground?.item2
        .toARGB32(),
    'colorScanButtonsForegroundLight':
        scanConfig.colorConfig.colorScanButtonsForeground?.item1.toARGB32(),
    'colorScanButtonsForegroundDark':
        scanConfig.colorConfig.colorScanButtonsForeground?.item2.toARGB32(),
    'colorScanPolygonLight':
        scanConfig.colorConfig.colorScanPolygon?.item1.toARGB32(),
    'colorScanPolygonDark':
        scanConfig.colorConfig.colorScanPolygon?.item2.toARGB32(),
    'colorBottomBarBackgroundLight':
        scanConfig.colorConfig.colorBottomBarBackground?.item1.toARGB32(),
    'colorBottomBarBackgroundDark':
        scanConfig.colorConfig.colorBottomBarBackground?.item2.toARGB32(),
    'colorBottomBarForegroundLight':
        scanConfig.colorConfig.colorBottomBarForeground?.item1.toARGB32(),
    'colorBottomBarForegroundDark':
        scanConfig.colorConfig.colorBottomBarForeground?.item2.toARGB32(),
    'colorTopBarBackgroundLight':
        scanConfig.colorConfig.colorTopBarBackground?.item1.toARGB32(),
    'colorTopBarBackgroundDark':
        scanConfig.colorConfig.colorTopBarBackground?.item2.toARGB32(),
    'colorTopBarForegroundLight':
        scanConfig.colorConfig.colorTopBarForeground?.item1.toARGB32(),
    'colorTopBarForegroundDark':
        scanConfig.colorConfig.colorTopBarForeground?.item2.toARGB32(),
    'textSizeBottomToolbar': scanConfig.textConfig.textSizeBottomToolbar,
    'textSizeTopToolbar': scanConfig.textConfig.textSizeTopToolbar,
    'textSizeScanButtons': scanConfig.textConfig.textSizeScanButtons,
    'textSizeTitle': scanConfig.textConfig.textSizeTitle,
    'textTitleScanPage': scanConfig.textConfig.textTitleScanPage,
    'textTitleEditPage': scanConfig.textConfig.textTitleEditPage,
    'textTitleFilterPage': scanConfig.textConfig.textTitleFilterPage,
    'textTitleCroppingPage': scanConfig.textConfig.textTitleCroppingPage,
    'textTitleArrangementPage':
        scanConfig.textConfig.textTitleArrangementPage,
    'textTitleConfirmationPage':
        scanConfig.textConfig.textTitleConfirmationPage,
    'textDocumentTitle': scanConfig.textConfig.textDocumentTitle,
    'textOnboardingTitle': scanConfig.textConfig.textOnboardingTitle,
    'textOnboardingMessage': scanConfig.textConfig.textOnboardingMessage,
    'textOnboardingCloseButton':
        scanConfig.textConfig.textOnboardingCloseButton,
    'textSizeOnboardingTitle': scanConfig.textConfig.textSizeOnboardingTitle,
    'textSizeOnboardingMessage':
        scanConfig.textConfig.textSizeOnboardingMessage,
    'textFocusHint': scanConfig.textConfig.textFocusHint,
    'textFirstPageHint': scanConfig.textConfig.textFirstPageHint,
    'textLastPageHint': scanConfig.textConfig.textLastPageHint,
    'textOnePageHint': scanConfig.textConfig.textOnePageHint,
    'textScanProgress': scanConfig.textConfig.textScanProgress,
    'textDeleteDialogCurrentPage':
        scanConfig.textConfig.textDeleteDialogCurrentPage,
    'textDeleteDialogAllPages':
        scanConfig.textConfig.textDeleteDialogAllPages,
    'textDeleteDialogCancel': scanConfig.textConfig.textDeleteDialogCancel,
    'confirmPages': scanConfig.confirmPages,
    'allowPageEditing': scanConfig.allowPageEditing,
  };

  dataToPass.addAll(addParaButton(
      'buttonEditRotate', scanConfig.buttonConfig.buttonEditRotate));
  dataToPass.addAll(addParaButton(
      'buttonEditCrop', scanConfig.buttonConfig.buttonEditCrop));
  dataToPass.addAll(addParaButton(
      'buttonEditFilter', scanConfig.buttonConfig.buttonEditFilter));
  dataToPass.addAll(addParaButton(
      'buttonEditArrange', scanConfig.buttonConfig.buttonEditArrange));
  dataToPass.addAll(addParaButton(
      'buttonEditRetake', scanConfig.buttonConfig.buttonEditRetake));
  dataToPass.addAll(addParaButton(
      'buttonEditDelete', scanConfig.buttonConfig.buttonEditDelete));
  dataToPass.addAll(addParaButton(
      'buttonEditFinish', scanConfig.buttonConfig.buttonEditFinish));
  dataToPass.addAll(addParaButton(
      'buttonCropExpand', scanConfig.buttonConfig.buttonCropExpand));
  dataToPass.addAll(addParaButton(
      'buttonCropSnap', scanConfig.buttonConfig.buttonCropSnap));
  dataToPass.addAll(addParaButton(
      'buttonCropFinish', scanConfig.buttonConfig.buttonCropFinish));
  dataToPass.addAll(addParaButton('buttonScanAutoCaptureOn',
      scanConfig.buttonConfig.buttonScanAutoCaptureOn));
  dataToPass.addAll(addParaButton('buttonScanAutoCaptureOff',
      scanConfig.buttonConfig.buttonScanAutoCaptureOff));
  dataToPass.addAll(addParaButton(
      'buttonScanTorch', scanConfig.buttonConfig.buttonScanTorch));
  dataToPass.addAll(addParaButton(
      'buttonScanCapture', scanConfig.buttonConfig.buttonScanCapture));
  dataToPass.addAll(addParaButton(
      'buttonScanFinish', scanConfig.buttonConfig.buttonScanFinish));
  dataToPass.addAll(addParaButton('buttonConfirmationFinish',
      scanConfig.buttonConfig.buttonConfirmationFinish));

  return methodChannel
      .invokeMethod<bool>('scanDocument', dataToPass)
      .then<bool>((bool? value) => value ?? false);
}