You need to enable JavaScript to run this app. Flutter设resizeToAvoidBottomInset为false仍被键盘顶起模态BottomSheet怎么办
优惠活动
大模型
产品
解决方案
定价
更多

Flutter设resizeToAvoidBottomInset为false仍被键盘顶起模态BottomSheet怎么办

我在开发Flutter应用时遇到了位置适配的异常:即便已将Scaffold的resizeToAvoidBottomInset属性设置为false,键盘弹出时仍会向上顶起模态BottomSheet,我希望模态BottomSheet能完全保持初始位置,不随键盘弹出发生偏移。
下面是当前用于实现模态BottomSheet的代码,同时附上演示该异常的录屏:

Scaffold(
    resizeToAvoidBottomInset: false,
    key: _scaffoldKey,
    body: ...
)

showModalBottomSheet(
  context: context,
  isScrollControlled: true,
  backgroundColor: Colors.transparent,
  builder: (context) => Container(
      height: MediaQuery.of(context).size.height * 0.8,
      decoration: new BoxDecoration(
        color: Colors.white,
        borderRadius: new BorderRadius.only(
          topLeft: const Radius.circular(25.0),
          topRight: const Radius.circular(25.0),
        ),
      ),
      child: SearchPlace((place, alreadyExists) {
        Navigator.pop(context);
        didSelectPlace(place, alreadyExists);
      }),
  ),
);

键盘弹出时BottomSheet被异常顶起上移的演示录屏
烦请提供可行的解决方案,感谢帮助。


内容的提问来源于stack exchange,提问作者Mircea Dragota

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.11.03 08:36:00