void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Row(
children: <Widget>[
Expanded(
child: Image.asset('images/dice1.png'),
),
],
),
),
);
}
}
答案 0 :(得分:1)
在您的pubspec.yaml
中添加assets
:
flutter:
assets:
- images/dice1.png
确保目录正确,此处有更多信息: https://flutter.dev/docs/development/ui/assets-and-images
答案 1 :(得分:0)
您必须返回runapp,或者可以使用箭头代替。
void main() => runApp(MyApp());