State of Bottomsheets
#method 1:
PersistentBottomSheetController _controller; // <------ Instance variable final _scaffoldKey = GlobalKey<ScaffoldState>(); // <---- Another instance variable . . . void _incrementBottomSheet(){ _controller.setState( (){ heightOfModalBottomSheet += 10; } ) } . void _createBottomSheet() async{ _controller = await _scaffoldKey.currentState.showBottomSheet( context: context, builder: (context) { return Container( height: heightOfModalBottomSheet, child: RaisedButton( onPressed: () { _incrementBottomSheet() }), ); }); }
#method 2:
showModalBottomSheet( context: context, builder: (context) { return StatefulBuilder( builder: (BuildContext context, StateSetter setState /*You can rename this!*/) { return Container( height: heightOfModalBottomSheet, child: RaisedButton(onPressed: () { setState(() { heightOfModalBottomSheet += 10; }); }), ); }); });