【发布时间】:2023-03-16 05:35:01
【问题描述】:
我在没有网络的情况下启动应用程序。 然后我使网络可用并单击 setState 按钮,图像仍然不可见。 有解决办法吗?
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Column(
children: <Widget>[
Container(
color: Colors.blue,
child: Image.network(
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3500755592,262843410&fm=26&gp=0.jpg'),
width: 100,
height: 100,
),
RaisedButton(
child: Text('setState'),
onPressed: () {
setState(() {});
},
),
],
));
}
【问题讨论】:
-
我发现当一个图片加载失败时,这个图片的url会被识别为不可用。再次请求同一图像时将返回 Null。有什么办法可以解决吗?
标签: flutter flutter-image