Commit b6e28277 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Disable menu button when bottom sheet open (#8319)

Otherwise tapping the menu button causes the bottom sheet to disappear and
reappear.

Fixes #8275
parent 0d2c9670
...@@ -10,10 +10,10 @@ class ListDemo extends StatefulWidget { ...@@ -10,10 +10,10 @@ class ListDemo extends StatefulWidget {
static const String routeName = '/list'; static const String routeName = '/list';
@override @override
ListDemoState createState() => new ListDemoState(); _ListDemoState createState() => new _ListDemoState();
} }
class ListDemoState extends State<ListDemo> { class _ListDemoState extends State<ListDemo> {
static final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>(); static final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
PersistentBottomSheetController<Null> _bottomSheet; PersistentBottomSheetController<Null> _bottomSheet;
...@@ -34,8 +34,8 @@ class ListDemoState extends State<ListDemo> { ...@@ -34,8 +34,8 @@ class ListDemoState extends State<ListDemo> {
_bottomSheet?.setState(() { }); _bottomSheet?.setState(() { });
} }
void showConfigurationSheet(BuildContext appContext) { void _showConfigurationSheet() {
_bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) { final PersistentBottomSheetController<Null> bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
return new Container( return new Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26)), border: new Border(top: new BorderSide(color: Colors.black26)),
...@@ -126,6 +126,18 @@ class ListDemoState extends State<ListDemo> { ...@@ -126,6 +126,18 @@ class ListDemoState extends State<ListDemo> {
), ),
); );
}); });
setState(() {
_bottomSheet = bottomSheet;
});
_bottomSheet.closed.whenComplete(() {
if (mounted) {
setState(() {
_bottomSheet = null;
});
}
});
} }
Widget buildListItem(BuildContext context, String item) { Widget buildListItem(BuildContext context, String item) {
...@@ -186,7 +198,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -186,7 +198,7 @@ class ListDemoState extends State<ListDemo> {
new IconButton( new IconButton(
icon: new Icon(Icons.more_vert), icon: new Icon(Icons.more_vert),
tooltip: 'Show menu', tooltip: 'Show menu',
onPressed: () { showConfigurationSheet(context); }, onPressed: _bottomSheet == null ? _showConfigurationSheet : null,
), ),
], ],
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment