【问题标题】:Reading images from a folder using flutter使用颤振从文件夹中读取图像
【发布时间】:2020-02-14 20:23:45
【问题描述】:

我想读取手机存储中“myImages”文件夹中的一些图像。我只需要列出这些图像。如何打开 myImages 文件夹并通过颤振列出其中的图像?

【问题讨论】:

    标签: image flutter directory path


    【解决方案1】:

    你可以像这样使用Image.file(File('FilePath'))

    class MyHomePage extends StatefulWidget {
      MyHomePage({Key key, this.title}) : super(key: key);
      final String title;
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
    
            title: Text(widget.title),
          ),
          body: Image.file(File('FilePath')),
    
        );
      }
    }
    

    【讨论】:

    • 非常感谢,文件夹名称是“myImages”,它在我的主路径上的存储中。那怎么能把这个路径代替你写的'FilePath'呢?
    • 您可以使用path_provider_ex: ^1.0.1 查找sdcard 路径。
    猜你喜欢
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    相关资源
    最近更新 更多