Flutter - 键盘出来时 ShowModalBottomSheet 不会上升

Flutter - ShowModalBottomSheet does not go up when the keyboard comes out

我通过 showModalBottomSheet 打开了一个新页面。但是,当你通过textformfield打开键盘时,出现页面做textformfield的现象。我不知道是什么问题。非常感谢您给我提示或答案。

InkWell buildAddBtn() {
 return InkWell(
   child: Icon(
     Icons.add,
     size: 30.0,
  ),
  onTap: () {
    showModalBottomSheet(
      context: context,
      isScrollControlled: true,
      builder: (BuildContext context) => SingleChildScrollView(
        child: Container(
          padding: EdgeInsets.only(
              bottom: MediaQuery.of(context).viewInsets.bottom),
          child: AddPage(logInUsr: usrEmail),
        ),
      ),
    );
  },
);
}

尝试使用 Flexible() 作为 showModalBottomSheet 的父级。 希望这有效!

1 创建占据所有高度的 modalBottomSheet

2 添加包含子项的列

  1. 扩展了一个弹出的监听器,所以我们的 sheet 将位于底部,而且当用户点击 sheet 顶部的区域时,这仍然会触发弹出
  2. YourBottomSheet

例子

showModalBottomSheet(
      context: ctx,
      isScrollControlled: true,
      backgroundColor: Colors.transparent,
      builder: (ctx) => Container(
          height: double.infinity,
          width: double.infinity,
          color: Colors.transparent,
          child: Column(
            children: [
              Expanded(
                child: GestureDetector(
                  onTap: () => Navigator.of(context).pop(),
                  child: Container(
                    color: Colors.transparent,
                  ),
                ),
              ),
              YourBottomSheet(),])));