I have implemented a showModalBottomSheet that calls a stateful widget. I would like for the stateful widget to be able to receive data from the showModalBottomSheet call, and, modify it.
Below is my parent class, the one that calls the 'showModalBottomSheet' function:
class _parentClass extends StatelessWidget {
bool testing = false; //This is the variable that I am trying to change.
@override
Widget build(BuildContext context) {
void _callModalBottomSheet() {
showModalBottomSheet(
context: context,
builder: (BuildContext bc) {
return Wrap(
children: <Widget>[
Container(
child: myStatefulWidget(testingValue: testing),
),
]);
});
print("Testing Value: $testing");
}
return Column(
children: <Widget>[
FlatButton(
child: Text("my button"),
onPressed: _callModalBottomSheet,
),
],
);
}
}
'myStatefulWidget' is actually another class implemented in a whole new file, thus, its only way to access the 'testing' variable is through its constructor (at least, the only way I know).
I have tried this, but it throws an error:
class myStatefulWidget extends StatefulWidget {
final testingValue;
myStatefulWidget({
this.testingValue,
});
//testingValue = !testingValue; //This line throws an error!
@override
myStatefulWidgetState createState() => myStatefulWidgetState();
}
//...
Thank you very much for your help!