对path_provider依赖项的getExternalStorageDirectory()有什么期望? [英] what expected have getExternalStorageDirectory() of path_provider dependency?

查看:65
本文介绍了对path_provider依赖项的getExternalStorageDirectory()有什么期望?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用flutter开发的应用程序,需要访问本地存储.该代码的预期返回值是什么?

I have an application that i develop with flutter and i need to acces local storage. what is expected return of that code?

我使用package path_provider:^ 1.2.2

i use the package path_provider:^1.2.2

var directory=await getExternalStorageDirectory();
print(directory.path)

我获得:/storage/emulated/0/Android/data/com.myapplication.application/files

而我希望具有/storage/emulated/0/.

我想知道这是否是一个错误.

I want to know if is not an error.

推荐答案

删除.getAbsolutePath(),就可以了.Environment.getExternalStoreDirectory()将为您提供制造商设置外部存储位置的路径. https://api.dartlang.org/stable/2.4.1/dart-core/String/substring.html 用于根据需要修剪路径...

Remove the .getAbsolutePath() and it will be fine. Environment.getExternalStoreDirectory() will give you the path to wherever the manufacture has set its external storage. https://api.dartlang.org/stable/2.4.1/dart-core/String/substring.html for trimming path as you need...

这篇关于对path_provider依赖项的getExternalStorageDirectory()有什么期望?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆