您也许可以使用中
showBottomSheet的
ScaffoldState。在此阅读更多有关showBottomSheet的信息。
这将显示bottomSheet并返回一个控制器
PersistentBottomSheetController。使用此控制器,您可以调用
controller.SetState((){})它将重新渲染bottomSheet的内容。这是一个例子
PersistentBottomSheetController _controller; // <------ Instance variablefinal _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() }), ); });}


