Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Network images keeps disappearing when scrolling list view in flutter?

I have a list view where the image from api is loaded, I noticed that the image keeps disappearing for few seconds when scrolling once in a while. Here is the code on the image part only:

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

like image 951
Manas Avatar asked Jul 16 '19 08:07

Manas


1 Answers

Change the cacheExtent value to 9999 and it works for me

ListView.builder(
    cacheExtent: 9999,
}
like image 83
Umer Waqas CEO Fluttydev Avatar answered Sep 30 '22 02:09

Umer Waqas CEO Fluttydev