I am new to flutter and this might be a very nooby question but I want to set state of a variable of one stateful widget from another Stateful widget.
Sharing a small snippet that reproduces the problem am facing.
FirstWidget.dart
class FirstWidget extends StatefulWidget {
@override
_FirstWidgetState createState() => _FirstWidgetState();
}
class _FirstWidgetState extends State<FirstWidget> {
bool _isDisabled = true;
@override
Widget build(BuildContext context) {
return Container(
// Doing Something with the flag isDisabled
);
}
}
SecondWidget.dart
class SecondWidget extends StatefulWidget {
@override
_SecondWidgetState createState() => _SecondWidgetState();
}
class _SecondWidgetState extends State<SecondWidget> {
@override
Widget build(BuildContext context) {
return Container(
// Here I want to update the isDisabled Flag of the First Widget.
);
}
}
I basically just want to know how do I update the value of a variable of one widget from another widget.
Thanks