模态底部工作表中忽略了SafeArea

时间:2020-03-28 15:24:05

标签: flutter

仅注意到,当showModalBottomSheet设置为isScrollControlled: true时,顶部的SafeArea被忽略了。(我希望我的模式适合屏幕)有人找到解决该问题的方法吗?

showModalBottomSheet(
  context: context,
  isScrollControlled: true,
  builder: (context) => MyModal(),
)

我的测试模式

class MyModal extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Column(
        children: <Widget>[
          Text('Modal'),
          Expanded(
              child: Container(
            color: Colors.red,
          ))
        ],
      ),
    );
  }
}

输出

enter image description here

我有点通过设置模态内容的高度来临时修复它

SafeArea(
      child: Container(
        height: MediaQuery.of(context).size.height - 80,
        child: Column(
          children: ...

输出

enter image description here

0 个答案:

没有答案