使用flutter从文件夹中读取图像

时间:2019-10-17 21:00:14

标签: image flutter directory path

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

1 个答案:

答案 0 :(得分:0)

您可以像这样使用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')),

    );
  }
}
相关问题