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

Make the floating action button respond to tap (#6095)

Fixes #6053
parent 0734edbe
...@@ -19,11 +19,11 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { ...@@ -19,11 +19,11 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_showBottomSheetCallback = showBottomSheet; _showBottomSheetCallback = _showBottomSheet;
} }
void showBottomSheet() { void _showBottomSheet() {
setState(() { // disable the button setState(() { // disable the button
_showBottomSheetCallback = null; _showBottomSheetCallback = null;
}); });
...@@ -47,18 +47,33 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { ...@@ -47,18 +47,33 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
}) })
.closed.then((_) { .closed.then((_) {
setState(() { // re-enable the button setState(() { // re-enable the button
_showBottomSheetCallback = showBottomSheet; _showBottomSheetCallback = _showBottomSheet;
}); });
}); });
} }
void _showMessage() {
showDialog(
context: context,
child: new Dialog(
content: new Text('You tapped the floating action button.'),
actions: <Widget>[
new FlatButton(
onPressed: () { Navigator.of(context).pop(); },
child: new Text('OK')
)
]
)
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
appBar: new AppBar(title: new Text('Persistent bottom sheet')), appBar: new AppBar(title: new Text('Persistent bottom sheet')),
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
onPressed: null, onPressed: _showMessage,
backgroundColor: Colors.redAccent[200], backgroundColor: Colors.redAccent[200],
child: new Icon(Icons.add) child: new Icon(Icons.add)
), ),
......
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