showActionSheet function
Future<int?>
showActionSheet({
- required BuildContext context,
- required List<
ActionSheetItem> items, - String? title,
- String? subtitle,
- String? cancelLabel = 'Cancel',
Shows an action sheet with a list of actions.
Implementation
Future<int?> showActionSheet({
required BuildContext context,
required List<ActionSheetItem> items,
String? title,
String? subtitle,
String? cancelLabel = 'Cancel',
}) =>
showBottomSheet<int>(
context: context,
child: BottomSheet(
title: title,
subtitle: subtitle,
content: Column(
children: <Widget>[
for (int i = 0; i < items.length; i++)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: _ActionSheetTile(
item: items[i],
onTap: items[i].enabled
? () => Navigator.of(context).pop(i)
: null,
),
),
],
),
actions: cancelLabel == null
? null
: <Widget>[
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(cancelLabel),
),
),
],
),
);