adaptive action bottom sheet
action bottom sheet that adapts to the platform (android/ios).
ios | android |
---|---|
getting started
add the package to your pubspec.yaml:
adaptive_action_sheet: ^1.0.8
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: 'item 1', onpressed: () {}),
bottomsheetaction(title: 'item 2', onpressed: () {}),
bottomsheetaction(title: 'item 3', onpressed: () {}),
],
cancelaction: cancelaction(title: '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
andbarriercolor
can be passed in to customize the appearance and behavior of persistent bottom sheets.
bottomsheetaction:
title
: the string that will appear in the title bar of the action 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)
cancelaction:
title
: the string that will appear in the title bar of the cancel action. (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)
Comments are closed.