Reputation: 289
I try to update a StatefulBuilder state form a showDialog, but I only can call the _setstate1 inside the StatefulBuilder. Is there a way to call _setstate1 from outside
this widget should be updated:
String image= "assets/images/1.png";
Widget updateMe(){
return StatefulBuilder(builder: (_context, _setState1) {
return Image.asset(image);
});
}
this showDialog widget should execute the update:
updateTheImage() {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Container(child: InkWell(
onTap: () {
_setState1(() {
String image= "assets/images/2.png";
});
},
child: Icon(Icons.check),
),)
);}
);
}
thanks
Upvotes: 1
Views: 593
Reputation: 172
can you explain more what are you trying to achieve? and in what way the dialog is connected to the updateMe()
function? it's a bit vague to be honest.
Upvotes: 0