最早使用Flutter 显示dialog的时候 flutter版本2.0.2 如下代码 可以使dialog高度自适应
Center(
child: Material(
borderRadius: BorderRadius.circular(10),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
height: height,
padding: EdgeInsets.only(
top: 20,
left: horizontal == null ? 15 : horizontal,
right: horizontal == null ? 15 : horizontal,
bottom: 20),
width: width == null ? (Get.mediaQuery.size.width - 30) : width,
color: ColorHelp.color254,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: list,
),
),
),
),
);
Get.dialog(
content,
barrierDismissible: barrierDismissible,
barrierColor: Color.fromRGBO(0, 0, 0, 0.6),
useSafeArea: false,
).then((value) {
dismissCall?.call();
});
目前使用的版本 3.5.0 使用相同的方式 发现 外层的container是撑满的,可使用如下写法 兼容
Get.dialog(Center(
child:Material(
color: Colors.transparent,
child: Column(
children: [
Expanded(child: Container()),
Container(
height: null,
width: Get.mediaQuery.size.width - 50,
alignment: Alignment.center,
// margin: EdgeInsets.only(left: 30,right: 30),
padding: EdgeInsets.only(bottom: 28),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10)
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: list,
),
),
Expanded(child: Container())
],
) ,
),
),useSafeArea: false);
希望可以帮到你,有问题欢迎讨论!!!