我似乎不能简单地将图像从硬盘加载到屏幕上。Image.network看起来很简单。但我不知道如何使用图像或Image.file。图像似乎需要一个流,所以我不认为这是我正在寻找的。
import 'package:flutter/material.dart';
import 'dart:io';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
File file = new File("Someimage.jpeg");
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Image.file(file), //doesn't work, but no errors
);
}
}我将Someimage添加到pubspec.yaml文件中,但这也不起作用:
assets:
- Someimage.jpeg有人能给我举个例子来说明这是怎么做到的吗?谢谢。
发布于 2018-04-14 20:06:29
如果您在资产中的映像可以使用image.asset构造函数
https://stackoverflow.com/questions/49835623
复制相似问题