getApplicationDocumentsDirectory is not working on flutter desktop (windows) getApplicationDocumentsDirectory is not working on flutter desktop (windows) dart dart

getApplicationDocumentsDirectory is not working on flutter desktop (windows)


String _localPath = (await _findLocalPath()) + Platform.pathSeparator + 'Download';final savedDir = Directory(_localPath);bool hasExisted = await savedDir.exists();if (!hasExisted) {  savedDir.create();}

Pubspec.yami

dependencies:  flutter:    sdk: flutter  cupertino_icons: ^0.1.3  path_provider: ^1.6.8 

Try to this code dear.


To get the desktop plugins to work i found i needed to copy the plugins provided by flutter specifically for desktop into my project. I also updated the yaml configuration.

Source for plugins. https://github.com/google/flutter-desktop-embedding/tree/master/plugins/flutter_plugins/path_provider_fde

Note: i believe these plugins will change and eventually become part of the default package installed.

Things like getApplicationDocumentsDirectory are provided by Flutter, but the windows implementation is currently in development, so you have to provide the additional plugins which have the windows/mac/linux implementation. Which can be found on the flutter desktop pages. (link above)

Below is what my folder looks like.

enter image description here

And my pubspec.yaml dependencies: logger: ^0.9.1 dependencies: auto_size_text: ^2.1.0 draggable_scrollbar: ^0.0.4 provider: ^4.0.1 flutter: sdk: flutter file_chooser: git: url: git://github.com/google/flutter-desktop-embedding.git path: plugins/file_chooser ref: 4ee135c path_provider: ^1.5.1 path_provider_macos: ^0.0.1 path_provider_fde: path: ./plugins/flutter_plugins/path_provider_fde window_size: path: ./plugins/window_size url_launcher: ^5.4.0 url_launcher_fde: path: ./plugins/flutter_plugins/url_launcher_fde


In pubspec.yaml file add (path_provider: ^1.6.24)import package in our file (import 'package:path_provider/path_provider.dart';)