image
😟问题阐述:怎么也无法加载,我是一脸懵逼,后面试了以下加入assest/就行了,我靠~
image
//AssetImage assetImage = new AssetImage('images/abc.jpg'); 出问题
//加入assets就没问题
AssetImage assetImage = new AssetImage('assets/images/abc.jpg');
return new MaterialApp(
title: "如何构建一个布局",
theme: new ThemeData(
primarySwatch: Colors.blue
),
home: Scaffold(
appBar: AppBar(title: Text("Fultter layout demo"),),
body: ListView(
children: <Widget>[
new Image(image: assetImage,width: 600,height: 240.0,fit: BoxFit.cover,),
titleSection,
buttonSection,
textSection,
],),
),
);
📣另外一点也要注意: - assets前面的缩减空格 ,可以会使Packages get获取不成功!!格式要规范正确
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/abc.jpg
- assets/images/abcc.png
📣不正确的缩进,例如👇
5caf56ee64fb3
📣结果就成这样了!😱
5caf56e3ccaff
网友评论