showBottomSheetByActions static method

Future showBottomSheetByActions(
  1. dynamic context, {
  2. required List<PQBottomSheetAction> actions,
  3. Color? backgroundColor = Colors.white,
  4. double? elevation,
  5. Clip? clipBehavior,
  6. Color? barrierColor,
  7. bool isScrollControlled = false,
  8. bool useRootNavigator = false,
  9. bool isDismissible = true,
  10. bool enableDrag = true,
  11. bool safeArea = true,
  12. RouteSettings? routeSettings,
  13. AnimationController? transitionAnimationController,
  14. 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,
  );
}