我有一个列表视图,其中加载了api中的图像,我注意到,当偶尔滚动一次时,图像会消失几秒钟.以下是图像部分的代码:

Container(
padding: EdgeInsets.only(top:5.0,left:15.0,right:1.0,bottom:0.0),
constraints: new BoxConstraints.expand(
   height: 130.0,
   width: 150.0,
),
decoration: new BoxDecoration(
            image: new DecorationImage(
            image: NetworkImage(artworksAndEventsFinal[index]['thumbnail']),fit: BoxFit.cover,),
            ),
           child: new Stack(
              children: <Widget>[
                   new Positioned(
                   right: 0.0,
                   bottom: 0.0,
                   child: Container(
                   height: 24.0,
                   padding: EdgeInsets.only(top:5.0,left:10.0,right:5.0,bottom:5.0),
             decoration: new BoxDecoration(
             color: Theme.of(context).primaryColor,
             ),
             child: new Text(artworksAndEventsFinal[index]['year'],
                    style: new TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 11.0,
                    color: Colors.white
                     )
                    ),
             )
            ),
            new Positioned(
                right: 3.0,
                top: 0.0,
                child: new Icon(Icons.favorite_border,color: 
                Colors.white,),
                ),
            ],
          )
        ),

enter image description here

推荐答案

列表视图在小部件可见时创建它.因此,只有可见的子对象拥有图像,消失的子对象删除小部件,而未加载的子对象不获取图像.

如果您想要缓存图像,请考虑使用包Cached_network_image

Dart相关问答推荐

Futures 和异步代码如何在 Dart 中工作?

flutter.io (dart) - 将填充设置为设备宽度的百分比?

如何在Flutter中制作视频缩略图?

停止从事件侦听器内部侦听事件

在`lib`文件夹中使用`src`子文件夹有什么好处吗

在 Dart 中定义一个接受参数的 getter

在小部件之间画一条线

IOS中Webview Flutter字体太小

Flutter:如何同步使用 SharedPreferences?

如何在Flatter中将图表线 colored颜色 更改为自定义 colored颜色 代码值

Flutter 扩展方法不起作用,它说undefined class和requires the extension-methods language feature

如何解决Id does not exist错误?

有没有更好的方法来解析 Dart 中的 int

如何从Flatter应用程序中导航到网页?(OAuth)

Dart:默认 gitignore?

dart 是否支持运算符重载

学习 Dart 好还是我必须使用基本的 javascript?

在 Dart 中,List.from 和 .of 以及 Map.from 和 .of 有什么区别?

如何在 Dart 中读取控制台输入/标准输入?

如何在 Dart 中进行整数除法?