create static method

NLClassifier create(
  1. String modelPath, {
  2. NLClassifierOptions? options,
})

Create NLClassifier from modelPath and optional options.

modelPath is the path of the .tflite model loaded on device.

throws FileSystemException If model file fails to load.

Implementation

static NLClassifier create(String modelPath, {NLClassifierOptions? options}) {
  if (options == null) {
    options = NLClassifierOptions();
  }
  final nativePtr =
      NLClassifierFromFileAndOptions(modelPath.toNativeUtf8(), options.base);
  if (nativePtr == nullptr) {
    throw FileSystemException("Failed to create NLClassifier.", modelPath);
  }
  return NLClassifier._(nativePtr);
}