Skip to content

Instantly share code, notes, and snippets.

@BbsonLin
Created December 28, 2018 05:15
Show Gist options
  • Save BbsonLin/5a6d9c46cdef67f954e4ce8776f0ea83 to your computer and use it in GitHub Desktop.
Save BbsonLin/5a6d9c46cdef67f954e4ce8776f0ea83 to your computer and use it in GitHub Desktop.
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