show static method
void
show({})
显示底部弹出框
一个封装了Flutter原生showModalBottomSheet的便捷组件,提供简洁的API和默认样式。
参数:
height:弹出框的高度- 如果大于1:表示绝对像素高度
- 如果小于等于1:表示屏幕高度的比例
- 默认值:300像素
child:弹出框的自定义内容,如果为null,将显示默认文本"这是一个底部弹出框"barrierColor:背景遮罩的颜色,默认值:透明色backgroundColor:弹出框的背景颜色borderRadius:弹出框的圆角设置,默认值:顶部左右16px圆角isScrollControlled:是否使用全屏高度,设置为true时,弹出框可以通过拖拽覆盖整个屏幕isDismissible:点击背景是否可以关闭弹出框enableDrag:是否允许通过拖拽关闭弹出框clipBehavior:裁剪行为
Implementation
static void show({
double height = 300,
Widget? child,
Color barrierColor = Colors.transparent,
Color backgroundColor = Colors.white,
BorderRadius? borderRadius,
bool isScrollControlled = true,
bool isDismissible = true,
bool enableDrag = true,
Clip? clipBehavior,
}) {
showModalBottomSheet(
context: Get.context!,
barrierColor: barrierColor,
backgroundColor: backgroundColor,
shape: RoundedRectangleBorder(
borderRadius:
borderRadius ??
BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
),
isScrollControlled: isScrollControlled,
isDismissible: isDismissible,
enableDrag: enableDrag,
clipBehavior: clipBehavior,
builder: (BuildContext context) {
var sHeight = 0.3;
if (height > 1) {
sHeight = height;
} else {
sHeight = MediaQuery.of(context).size.height * height;
}
return SizedBox(
height: sHeight,
child: Center(
child:
child ??
Text(
'这是一个底部弹出框',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.black,
),
),
),
);
},
);
}