invoke method

Future<bool> invoke({
  1. required dynamic onResult(
    1. T extractionResult
    ),
  2. required dynamic onFailure(
    1. DigifiedError
    ),
  3. required dynamic onUploadProgress(
    1. int,
    2. int
    ),
  4. required dynamic onUploadingDone(
    1. int
    ),
})

Implementation

Future<bool> invoke(
    {required Function(T extractionResult) onResult,
    required Function(DigifiedError) onFailure,
    required Function(int, int) onUploadProgress,
    required Function(int) onUploadingDone}) async {
  _onResult = onResult;
  _onFailure = onFailure;
  _onUploadProgress = onUploadProgress;
  _onUploadingDone = onUploadingDone;

  switch (T) {
    case IdExtractionResult:
      sendType = SendConstants.egyptianId;
      break;
    case GenericIdExtractionResult:
      sendType = SendConstants.genericId;
      break;
    case PassportExtractionResult:
      sendType = SendConstants.passport;
      break;
    case VehicleLicenseExtractionResult:
      sendType = SendConstants.vehicleLicense;
      break;
    default: //
      sendType = SendConstants.selfie;
      break;
  }

  return sendToNative({
    SendConstants.sendType: sendType
  });
}