in this code which i used in my application i want to cache images during i scroll grid view, basically when i scroll grid view that cause reload again images and cause of getting speeding low during scroll
is any way to cache images before put them into GridView like with ImageCache?
StreamBuilder<List<MediaModel>>(
stream: _globalBloc.storageMediaBloc.imagesMedia$,
builder: (context, snapshot) {
final List<MediaModel> _allImages = snapshot.data;
_allImages.map((image) => mediaFoldersList.add(MediaDropDownStructure(image.folder, image.folder)));
final MediaModel _all = _allImages[1];
return GridView.builder(
controller: scrollController,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 5.0,
crossAxisSpacing: 5.0,
), //change the numb
itemBuilder: (context, index) {
return AspectRatio(
aspectRatio:1.0,
child: Image(image: FileImage(File('${_all.files[index]}')),fit: BoxFit.cover,));
},
itemCount: _all.files.length,
);
}
),
builderconstructor, use the normal/unnamed constructor.