当我尝试运行图像资产没有正确加载时,我得到一个例外:
抛出以下断言解析图像编解码器:无法加载资产:/ images/p8.png`
几周前它正在运作,现在它停止了.我试图从不同的PC和Mac运行(使用模拟器),但仍然无法加载图像.而是正确加载字体.
这是我加载图像的方式,它们是在里面呈现的,GridView
下面是代码:
return new Expanded(
child: new GridView.count(
crossAxisCount: 2,
padding: const EdgeInsets.fromLTRB(16.0, 25.0, 16.0, 4.0),
children: <Widget>[
new MaterialButton(
onPressed: () {
Navigator.of(context).pushNamed('/biliardo');
},
child: new Column(
children: <Widget>[
new Image(
//parte importante, definire gli asset per trovarli più velocemnte
//si inseriscono nel pubspec.yaml
image: new AssetImage('/images/p8.png'),
height: 100.0,
width: 100.0,
),
new Text(
"BILIARDO",
style: new TextStyle(
color: (darkTheme) ? Colors.blue : Colors.black,
),
)
],
),
),
.....
);
Run Code Online (Sandbox Code Playgroud)
pubsec.yaml文件代码:
flutter:
uses-material-design: …Run Code Online (Sandbox Code Playgroud)