Unhandled Exception: MissingPluginException No method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider

При запуске, приложение зависает, появляется черный экран и все, больше ничего не происходит. Запуск через консоль (flutter run --release) выдает ошибку:

E/flutter ( 8422): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)

E/flutter ( 8422): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156)
E/flutter ( 8422): <asynchronous suspension>
E/flutter ( 8422): #1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:139)
E/flutter ( 8422): <asynchronous suspension>
E/flutter ( 8422): #2      main.<anonymous closure> (package:mylibrary/main.dart:26)
E/flutter ( 8422): <asynchronous suspension>
E/flutter ( 8422):

Версия:

Flutter 2.0

environment:
  sdk: ">=2.12.0 <3.0.0"

Код:

Future<void> main() async {
    WidgetsFlutterBinding.ensureInitialized();

   String? applicationDocumentsDirectory;

   await getApplicationDocumentsDirectory().then((value) {
       applicationDocumentsDirectory = value.path;
       print("applicationDocumentsDirectory === $applicationDocumentsDirectory");
   });

  runApp(
    MyApp(
      initArgs: {
        'applicationDocumentsDirectory': applicationDocumentsDirectory,
      },
    ),
  );

}


class MyApp extends StatelessWidget {
  final Object initArgs;

  MyApp({
    required this.initArgs,
  });

  @override
  Widget build(BuildContext context) {
    Map initArgs = this.initArgs as Map;
    final String applicationDocumentsDirectory = initArgs['applicationDocumentsDirectory'];

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('en', 'US'),
        const Locale('ru', 'RU'),
      ],
      title: "",
      home: MultiProvider(
        providers: [
          ChangeNotifierProvider<BottomProvider>(create: (context) => BottomProvider()),
        ],
        child: HomePage(
          applicationDocumentsDirectory: applicationDocumentsDirectory,
          title: "",
        ),
      ),
      routes: {
        '/book_page': (context) => BookPage(),
      },
    );
  }
}

В файле pubspec импортированы следующие библиотеки:

dependencies:
  flutter:
    sdk: flutter

  flutter_localizations:
    sdk: flutter

  flutter_launcher_icons: ^0.9.0
  provider: ^5.0.0
  path_provider: ^2.0.1
  sqflite: ^2.0.0+2
  intl: ^0.17.0
  flutter_rating_bar: ^4.0.0
  image_picker: ^0.7.3

Если убрать image_picker то приложение запускается как надо. Я во Flutter-е новичок, думал может быть библиотеки конфликтуют path_provider: ^2.0.1 и image_picker: ^0.7.3 .. Поэтому скопировал полностью пример path_provider и вставил туда все свои зависимости, в первую очередь image_picker, но там пример работает и не зависает. Что я делаю не так? Подскажите пожалуйста))

flutter doctor выдает все окей))


Ответы (0 шт):