gpt4 book ai didi

android - getApplicationDocumentsDirectory 不适用于 flutter 桌面(Windows)

转载 作者:行者123 更新时间:2023-12-03 03:22:32 24 4
gpt4 key购买 nike

如何在 Windows 上的 Flutter 桌面中保存和打开文件。 getApplicationDocumentsDirectory 不适用于 Windows 应用程序的 flutter 桌面

Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
print('$directory');
return directory.path;
}

抛出错误。
Exception has occurred
MissingPluginException (MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider))

最佳答案

为了让桌面插件工作,我发现我需要将 Flutter 专门为桌面提供的插件复制到我的项目中。我还更新了 yaml 配置。

插件的来源。
https://github.com/google/flutter-desktop-embedding/tree/master/plugins/flutter_plugins/path_provider_fde

注意:我相信这些插件会改变并最终成为默认安装包的一部分。

像 getApplicationDocumentsDirectory 这样的东西是 Flutter 提供的,但是 windows 实现目前正在开发中,所以你必须提供具有 windows/mac/linux 实现的附加插件。可以在 flutter 桌面页面上找到。 (以上链接)

下面是我的文件夹的样子。

enter image description here

还有我的 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

关于android - getApplicationDocumentsDirectory 不适用于 flutter 桌面(Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61626825/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com