I want to change a bool value when the image is loaded.
The code is the following:
child: Image.network(
_db.image.path,
loadingBuilder: (BuildContext context,
Widget child,
ImageChunkEvent loadingProgress) {
if (loadingProgress == null) {
widget.isFetched = true;
print('fetched');
return Container(
width: 200,
child: child,
);
}
return Container(
width: 200,
height: 200,
child: Center(
child: CircularProgressIndicator(
value: loadingProgress
.expectedTotalBytes !=
null
? loadingProgress
.cumulativeBytesLoaded /
loadingProgress
.expectedTotalBytes
: null,
),
),
);
},
),
Somehow the widget.isFeched=true
gets triggered right after the screen appears and then again when the image is loaded.
What is the solution to avoid it and only change the value to true when the image is loaded?