Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Created January 29, 2019 13:33
Show Gist options
  • Save ashishrawat2911/d36a00e2cdfdb476cfac2d487e7644f2 to your computer and use it in GitHub Desktop.
Save ashishrawat2911/d36a00e2cdfdb476cfac2d487e7644f2 to your computer and use it in GitHub Desktop.
void showCupertinoSheet<T>({BuildContext context}) {
showCupertinoModalPopup<T>(
context: context,
builder: (BuildContext context) => CupertinoActionSheet(
title: const Text('Choose Options'),
message: const Text('Your options are '),
actions: <Widget>[
CupertinoActionSheetAction(
child: const Text('One'),
onPressed: () {
Navigator.pop(context, 'One');
},
),
CupertinoActionSheetAction(
child: const Text('Two'),
onPressed: () {
Navigator.pop(context, 'Two');
},
)
],
cancelButton: CupertinoActionSheetAction(
child: const Text('Cancel'),
isDefaultAction: true,
onPressed: () {
Navigator.pop(context, 'Cancel');
},
)),
).then<void>((T value) {
Scaffold.of(context).showSnackBar(new SnackBar(
content: new Text('You clicked $value'),
duration: Duration(milliseconds: 50),
));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment