startLiveness method

  1. @override
Future<EkycResult?> startLiveness(
  1. String livenessType,
  2. String? faceImageBase64
)
override

Implementation

@override
Future<EkycResult?> startLiveness(
    String livenessType, String? faceImageBase64) async {
  final arguments = {};
  arguments.putIfAbsent("livenessType", () => livenessType);
  arguments.putIfAbsent("faceImageBase64", () => faceImageBase64);

  try {
    final String? result =
        await methodChannel.invokeMethod('startLivenessScan', arguments);
    if (result == null || result.isEmpty) {
      return null;
    }

    return ekycResultFromJson(result);
  } on PlatformException catch (e) {
    if ((e.message ?? '').contains('FACE_NOT_FOUND') ||
        (e.message ?? '').contains('NO_FACE_FOUND')) {
      throw NexIdException(NexIdException.faceNotFound);
    }

    throw NexIdException(e.message ?? '');
  }
}