From 28a9a6b48c83a577138ddccfafed6058fa90eb62 Mon Sep 17 00:00:00 2001 From: Nan Kim Date: Sat, 10 Oct 2020 01:08:13 +0900 Subject: [PATCH] Add sample code for CupertinoActionSheet (#65274) --- .../lib/src/cupertino/action_sheet.dart | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/flutter/lib/src/cupertino/action_sheet.dart b/packages/flutter/lib/src/cupertino/action_sheet.dart index a82f56c2414..1f7862983fe 100644 --- a/packages/flutter/lib/src/cupertino/action_sheet.dart +++ b/packages/flutter/lib/src/cupertino/action_sheet.dart @@ -98,6 +98,55 @@ const double _kDividerThickness = 1.0; /// [showCupertinoModalPopup], which displays the action sheet by sliding it up /// from the bottom of the screen. /// +/// {@tool snippet} +/// This sample shows how to use a [CupertinoActionSheet]. +/// The [CupertinoActionSheet] shows an alert with a set of two choices +/// when [CupertinoButton] is pressed. +/// +/// ```dart +/// class MyStatefulWidget extends StatefulWidget { +/// @override +/// _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); +/// } +/// +/// class _MyStatefulWidgetState extends State { +/// @override +/// Widget build(BuildContext context) { +/// return CupertinoPageScaffold( +/// child: Center( +/// child: CupertinoButton( +/// onPressed: () { +/// showCupertinoModalPopup( +/// context: context, +/// builder: (BuildContext context) => CupertinoActionSheet( +/// title: const Text('Title'), +/// message: const Text('Message'), +/// actions: [ +/// CupertinoActionSheetAction( +/// child: const Text('Action One'), +/// onPressed: () { +/// Navigator.pop(context); +/// }, +/// ), +/// CupertinoActionSheetAction( +/// child: const Text('Action Two'), +/// onPressed: () { +/// Navigator.pop(context); +/// }, +/// ) +/// ], +/// ), +/// ); +/// }, +/// child: Text('CupertinoActionSheet'), +/// ), +/// ), +/// ); +/// } +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [CupertinoActionSheetAction], which is an iOS-style action sheet button.