showModalBottom<T> static method

Future<T?> showModalBottom<T>({
  1. required Widget child,
  2. Widget? title,
  3. Widget? leading,
  4. List<Widget>? actions,
  5. Widget? bottom,
  6. EdgeInsetsGeometry? padding,
  7. double? minHeight,
  8. bool showTitle = true,
  9. bool isScrollControlled = true,
  10. bool useSafeArea = true,
  11. Color? backgroundColor,
})

显示底部模态框

Implementation

static Future<T?> showModalBottom<T>({
  required Widget child,
  Widget? title,
  Widget? leading,
  List<Widget>? actions,
  Widget? bottom,
  EdgeInsetsGeometry? padding,
  double? minHeight,
  bool showTitle = true,
  bool isScrollControlled = true,
  bool useSafeArea = true,
  Color? backgroundColor,
}) async {
  final context = ComContext.context;
  final boxConstraints =
      minHeight != null ? BoxConstraints(minHeight: minHeight) : null;

  return await showModalBottomSheet(
    context: context,
    isScrollControlled: isScrollControlled,
    useSafeArea: useSafeArea,
    constraints: boxConstraints,
    backgroundColor: backgroundColor ?? Theme.of(context).dialogTheme.backgroundColor,
    builder: (BuildContext context) {
      return Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          if (showTitle)
            ComTitleBar(
              title: title,
              leading: leading,
              actions: actions,
            ),
          if (bottom != null) bottom,
          ConstrainedBox(
            constraints: BoxConstraints(
              maxHeight:
                  MediaQuery.of(context).size.height * _defaultModalHeight,
            ),
            child: SingleChildScrollView(
              padding: EdgeInsets.only(
                bottom: MediaQuery.of(context).padding.bottom +
                    MediaQuery.of(context).viewInsets.bottom,
              ),
              child: child,
            ),
          ),
        ],
      );
    },
  );
}