A action bottom sheet that adapts to the platform (Android/iOS).
useRootNavigator
parameter (optional) to set useRootNavigator of showCupertinoModalPopup
(Default true) and useRootNavigator of showModalBottomSheet
(Default false)
showAdaptiveActionSheet(
context: context,
title: const Text('Title'),
useRootNavigator: true,
actions: <BottomSheetAction>[
BottomSheetAction(title: const Text('Item 1'), onPressed: (context) {}),
BottomSheetAction(title: const Text('Item 2'), onPressed: (context) {}),
BottomSheetAction(title: const Text('Item 3'), onPressed: (context) {}),
],
cancelAction: CancelAction(title: const Text('Cancel')),// onPressed parameter is optional by default will dismiss the ActionSheet
);
showMaterialBottomSheet
with a SafeAreashowAdaptiveActionSheet(
context: context,
title: const Text('Title'),
actions: <BottomSheetAction>[
BottomSheetAction(title: const Text('Item 1'), onPressed: (context) {}),
BottomSheetAction(title: const Text('Item 2'), onPressed: (context) {}),
BottomSheetAction(title: const Text('Item 3'), onPressed: (context) {}),
],
cancelAction: CancelAction(title: const Text('Cancel')),// onPressed parameter is optional by default will dismiss the ActionSheet
);
title
type from String to WidgetVersion 1.1.0 or later | Version 1.0.12 or earlier |
---|---|
|
|
showAdaptiveActionSheet(
context: context,
actions: <BottomSheetAction>[
BottomSheetAction(
title: 'Add',
onPressed: () {},
leading: const Icon(
Icons.add,
size: 25,
),
trailing: const Icon(
Icons.delete,
size: 25,
color: Colors.red,
),
textAlign: TextAlign.start,
),
],
cancelAction: CancelAction(title: 'Cancel'),
);
textStyle
parameter for each action.
showAdaptiveActionSheet(
context: context,
actions: <BottomSheetAction>[
BottomSheetAction(
title: 'Item 1',
onPressed: () {},
textStyle: const TextStyle(
fontSize: 25,
color: Colors.blueAccent,
),
),
BottomSheetAction(title: 'Item 2', onPressed: () {}),
],
cancelAction: CancelAction(// onPressed parameter is optional by default will dismiss the ActionSheet
title: 'Cancel',
textStyle: const TextStyle(
fontSize: 25,
color: Colors.blueAccent,
),
),
);