-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageNetwork is not reloading on state changes #17
Comments
Send me an example code for me to test and solve, |
I've encapsulated the ImageNetwork into a widget and established a callback function for the onTap event. Subsequently, I utilize this widget within another widget. To update the display, I use setState to replace the original widget and then override it. You can refer to below: class NetImage extends StatelessWidget {
final String filePath;
final void Function() onPressed;
const NetImage({Key? key, required this.filePath, required this.onPressed})
: super(key: key);
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return ImageNetwork(
image: filePath,
width: constraints.maxWidth,
height: constraints.maxHeight,
fitWeb: BoxFitWeb.scaleDown,
onTap: () => onPressed(),
);
});
}
}
//another widget
void getImage() async {
XFile? xfile = await ImagePicker.picker();
if (xfile != null) {
setState(() {
filePath = xfile.path;
widget.getFilePath(xfile.path);
inner = NetImage(
filePath: filePath,
onPressed: () {
setState(() {
inner = addImage;
});
getImage();
},
);
});
}
} |
Any update on this.... |
I was having a similar issue, but solved it using a UniqueKey() on the ImageNetwork widget.
|
I am using RiverPod to set a new state, replacing the URL in my ImageNetwork. But nothing happens. With normal Image.Network etc. it works well. But ImageNetwork just won't be build with the new URL.
The text was updated successfully, but these errors were encountered: