showBottomSheetByActions static method
Future
showBottomSheetByActions(
- dynamic context, {
- required List<
PQBottomSheetAction> actions, - Color? backgroundColor = Colors.white,
- double? elevation,
- Clip? clipBehavior,
- Color? barrierColor,
- bool isScrollControlled = false,
- bool isDismissible = true,
- bool enableDrag = true,
- bool safeArea = true,
- RouteSettings? routeSettings,
- AnimationController? transitionAnimationController,
- ShapeBorder? shape = const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(16.0))),
显示底部按钮区域,使用bottom sheet的形式
Implementation
static Future showBottomSheetByActions(
context, {
required List<PQBottomSheetAction> actions,
Color? backgroundColor = Colors.white,
double? elevation,
Clip? clipBehavior,
Color? barrierColor,
bool isScrollControlled = false,
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
bool safeArea = true,
RouteSettings? routeSettings,
AnimationController? transitionAnimationController,
ShapeBorder? shape = const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16.0)),
),
}) async {
List<Widget> children = [];
double height = 0.0;
actions.forEach((e) {
// height += e.height;
children.add(GestureDetector(
onTap: () async{
await e.onTap?.call();
if (e.autoPop) {
var result = e.result?.call(e);
dismiss(context, result: result);
}
},
// padding: EdgeInsets.zero,
child: Container(
width: double.infinity,
alignment: Alignment.center,
padding: e.padding,
margin: e.margin,
decoration: BoxDecoration(
color: e.color,
border: Border(
bottom: BorderSide(color: e.dividerLineColor, width: 0.5),
),
),
child: PQText.lines(
e.text,
color: e.textColor,
fontSize: e.fontSize,
fontWeight: e.fontWeight,
maxLines: e.maxLines,
),
),
));
});
return await showBottomSheet(
context,
// SizedBox(height: height, child: Column(children: children)),
Column(mainAxisSize: MainAxisSize.min, children: children),
backgroundColor: backgroundColor,
elevation: elevation,
barrierColor: barrierColor,
isScrollControlled: isScrollControlled,
useRootNavigator: useRootNavigator,
isDismissible: isDismissible,
enableDrag: enableDrag,
safeArea: safeArea,
routeSettings: routeSettings,
transitionAnimationController: transitionAnimationController,
shape: shape,
);
}