I just want to ask if is there a better way to know if an image successfully loads and then place it in a bool state using Riverpod?
Right now I have this code that looks like this:
final validPhotoProvider = StateProvider<bool>((ref) => false);
Image.network(
photoUrl,
loadingBuilder: (context, child, loadingProgress){
if(loadingProgress == null){ //means image has finished loading.
ref.read(validPhotoProvider).state = true;
return child;
}
return CircularProgressIndicator();
},
),
As you can see I am relying on the builder to know if the image was loaded. Is there a better way to do this as I know this kind of method is not good as it may result in a bad state eventually.