You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter 3.19版本平板端BottomModalSheet无法占满全屏宽度的问题求助

Flutter 3.19版本平板端BottomModalSheet无法占满全屏宽度的问题求助

最近升级到Flutter 3.19版本后,我在平板设备上遇到了个棘手的问题——底部模态框(BottomModalSheet)没法占满整个屏幕宽度。我尝试过给容器添加BoxConstraints设置minWidth: double.infinity,也试过把Expanded作为BottomModalSheet的子组件,但都没能解决问题。

以下是我当前的实现代码:

showModalBottomSheet<void>(
  backgroundColor: Colors.yellow,
  context: context,
  builder: (BuildContext context) {
    return Container(
      constraints: const BoxConstraints(
        minWidth: double.infinity,
        minHeight: double.infinity,
      ),
      width: MediaQuery.of(context).size.width,
      height:MediaQuery.of(context).size.height,
      //color: Colors.amber,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            const Text('Modal BottomSheet'),
            ElevatedButton(
              child: const Text('Close BottomSheet'),
              onPressed: () => Navigator.pop(context),
            ),
          ],
        ),
      ),
    );
  }
);

现在的模态框宽度无法铺满平板屏幕,我需要让它占满平板的100%宽度,有没有大佬能帮忙看看怎么解决这个问题?

备注:内容来源于stack exchange,提问作者hail1401

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 07:08:09