Adaptive action sheet

pub package

A action bottom sheet that adapts to the platform (Android/iOS).

iOSAndroid
n1n2

Getting Started

Add the package to your pubspec.yaml:

 adaptive_action_sheet: ^1.1.0

In your dart file, import the library:

import 'package:adaptive_action_sheet/adaptive_action_sheet.dart';

Instead of using a showModalBottomSheet use showAdaptiveActionSheet Widget:

showAdaptiveActionSheet(
   context: context,
   title: const Text('Title'),
   actions: <BottomSheetAction>[
      BottomSheetAction(title: const Text('Item 1'), onPressed: () {}),
      BottomSheetAction(title: const Text('Item 2'), onPressed: () {}),
      BottomSheetAction(title: const Text('Item 3'), onPressed: () {}),
   ],
   cancelAction: CancelAction(title: const Text('Cancel')),// onPressed parameter is optional by default will dismiss the ActionSheet
);

Parameters:

showAdaptiveActionSheet:

  • actions: The Actions list that will appear on the ActionSheet. (required)
  • cancelAction: The optional cancel button that show under the actions (grouped separately on iOS).
  • title: The optional title widget that show above the actions.
  • The optional backgroundColor and barrierColor can be passed in to customize the appearance and behavior of persistent material bottom sheets(Android only).

BottomSheetAction:

  • title: The primary content of the action sheet item. (required)
  • onPressed: The callback that is called when the action item is tapped. (required)
  • textStyle: The TextStyle to use for the title text. (optional)
  • textAlign: How the title should be aligned horizontally. (optional)
  • leading: A widget to display before the title. Typically an Icon widget. (optional)
  • trailing: A widget to display after the title. Typically an Icon or a CircleAvatar widget. (optional)

CancelAction:

  • title: The primary content of the cancel action sheet item. (required)
  • onPressed: The callback that is called when the action item is tapped. onPressed is optional by default will dismiss the Action Sheet.
  • textStyle: The TextStyle to use for the title text. (optional)

Libraries

adaptive_action_sheet