Search code examples
androidflutterdartflutter-plugintflite

MissingPluginException in Flutter with tflite


I am trying to use the tflite package in my Flutter app, but I am encountering a MissingPluginException when attempting to load a model. Here are the details:

Flutter Version:

  • Flutter 3.24.4

Dependencies:

dependencies:
  flutter:
    sdk: flutter
  tflite: ^1.1.2

Code:

Future<void> loadModel() async {
  try {
    var resultant = await Tflite.loadModel(
      model: "assets/model.tflite",
    );
    print("Result after loading model: $resultant");
  } catch (e) {
    print("Error loading model: $e");
  }
}

Error:

Error loading model: MissingPluginException(No implementation found for method loadModel on channel tflite)

What I Have Tried:

  • Ensured that all dependencies are correctly installed.

  • Restarted the application multiple times. Already tried flutter clean.

  • Verified the asset path for the model file.

  • I am using the latest version of the plugin.

Environment:

  • OS: Windows

  • Android Emulator: sdk gphone16k x86 64

Any help would be greatly appreciated!


Solution

  • tflite package was not updated since 3 years ago, this error probably because the package is not compatible with the current flutter version. Try tflite_flutter package instead, it was released 55 days ago.