Created
December 28, 2018 05:15
-
-
Save BbsonLin/5a6d9c46cdef67f954e4ce8776f0ea83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class CustomActionPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text("Custom Action Page")), | |
body: Center( | |
child: CustomActionButton( | |
doAction: openDialog, | |
), | |
), | |
); | |
} | |
openDialog(context) { | |
showDialog( | |
context: context, | |
builder: (context) { | |
return AlertDialog( | |
content: Text( | |
"It's an alert", | |
), | |
actions: <Widget>[ | |
FlatButton( | |
child: const Text('OK'), | |
onPressed: () { | |
Navigator.pop(context); | |
}, | |
) | |
], | |
); | |
}, | |
); | |
} | |
} | |
class CustomActionButton extends StatelessWidget { | |
final Function doAction; | |
const CustomActionButton({Key key, this.doAction}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return RaisedButton( | |
child: Text("Press me"), | |
onPressed: () { | |
doAction(context); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment