The method 'getApplicationDocumentsDirectory' isn't defined for the type '_MyAppState'

3,397

Solution 1

You have to install path provider package by running flutter pub add path_provider in your terminal. If you already installed it. check whether you are importing it to your file.

Solution 2

Import this...

import 'package:path_provider/path_provider.dart';
Share:
3,397
Nadia Nadou
Author by

Nadia Nadou

Updated on December 30, 2022

Comments

  • Nadia Nadou
    Nadia Nadou over 1 year

    so a part of my code is

    
     Future<void> _loadModel() async {
        final bytes =
            await rootBundle.load('assets/deepspeech-0.9.3-models.tflite');
        final directory = (await getApplicationDocumentsDirectory()).path;
    
    

    And i keep getting the error:

    The method 'getApplicationDocumentsDirectory' isn't defined for the type '_MyAppState'.
    Try correcting the name to the name of an existing method, or defining a method named 'getApplicationDocumentsDirectory'
    

    What should i do? help me please!

  • nima
    nima over 2 years
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: stackoverflow.com/help/how-to-answer . Good luck 🙂