Reputation: 18157
How is it that "http://lorempixel.com/300/300/" returns the same image for all the grid tiles in the following example?
Widget build(BuildContext context) {
return GridView.builder(
itemCount: 100,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 2,
mainAxisSpacing: 2,
),
itemBuilder: (BuildContext context, int index) {
return Container(
color: Colors.grey,
child: Center(child: Image.network("http://lorempixel.com/300/300/")),
);
},
);
}
It seems that the result of the first request to "http://lorempixel.com/300/300" is used for all images. Why?
Upvotes: 1
Views: 115
Reputation: 7889
It's due to the structure of Image
widget and its Image.network
constructor which caches all Images
loaded through it. They mention that in the Image widget documentation :
All network images are cached regardless of HTTP headers.
Upvotes: 1