我似乎不能简单地将图像从硬盘加载到屏幕上.image.network看起来很简单.但是我不知道如何使用Image或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
);
}
}
我在pubspec中添加了一些图片.yaml文件,但这也不起作用:
assets:
- Someimage.jpeg
有人能给我举个例子说明这是怎么做的吗?谢谢.