flutter showModalBottomSheet底部弹窗设置自适应高度设置

发布时间 2023-09-21 17:13:38作者: 慕雪琳鸢

mainAxisSize 属性用于指定 RowColumn 主轴上的大小调整。当设置为 MainAxisSize.min 时,主轴会根据子组件的实际大小进行调整,尽可能地缩小主轴的尺寸。

这意味着,如果你在一个 Column 中将 mainAxisSize 设置为 MainAxisSize.min,它将根据所有子组件的最小高度来调整自身的高度,以便尽可能地减小垂直空间的使用。

showModalBottomSheet(
context: parentContext,
backgroundColor: Colors.transparent,
barrierColor: Colors.transparent,
isDismissible: true,
// 点击外部区域是否关闭弹窗,默认true
clipBehavior: Clip.none,
builder: (BuildContext context) {
payContext = context; // 记录 Pay context

return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
      ]
    )
  }
)