createService method Null safety

Future<FacerecService> createService()

Initializes the facerec library (can be called only once).

By default it is recommended to use FaceSdkPlugin.createFacerecService.

Implementation

static Future<FacerecService> createService() async {
  final String dataDirectory = await loadAssets();
  final String libraryDirectory = await getLibraryDirectory();
  final String facerecConfDir = "$dataDirectory/conf/facerec";
  final String licenseDir = "$dataDirectory/license";
  final String dllPath = "$libraryDirectory/${FaceSdkPlugin.nativeLibName}";
  final DynamicLibrary dylib = DynamicLibrary.open(dllPath);

  final createService =
      dylib.lookupFunction<_facerecConstructor, _facerecConstructor>(_c_namespace + 'FacerecService_constructor2');

  final exception = _getException();
  final pointer =
      createService(facerecConfDir.toNativeUtf8(), licenseDir.toNativeUtf8(), dllPath.toNativeUtf8(), exception);
  checkException(exception, dylib);

  return FacerecService(dylib, pointer, facerecConfDir, dllPath);
}