flutter - 在 ListView 中的键盘上方滚动 TextFormField

我的应用中有以下抽屉:

当我按下密码 TextFormField 时,我得到以下信息:

如您所见,密码 TextFormField 已被覆盖。我试图解决这个问题,建议 here :

class _LoginDrawer extends State<LoginDrawer> {
  static var _listViewScrollController = new ScrollController();

  @override
  Widget build(BuildContext context) => new Drawer(
    child: new ListView(
      controller: _listViewScrollController,
      children: <Widget>[
        // ...
        new Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0),
          child: new GestureDetector(
            onTap: () {
              SchedulerBinding.instance.addPostFrameCallback((_) {
                _listViewScrollController.jumpTo(
                 _listViewScrollController.position.maxScrollExtent);
              });
            },
            child: new TextFormField(
                obscureText: true,
                decoration: new InputDecoration(labelText: "Password")),
          ),
        ),
      ],
    ),
  );
}

但这并不能解决问题,该应用程序的行为与以前相同。还有一些人建议使用反转的 ListView 然后使用 listViewController.jumpTo(0.0) 但这导致了不需要的效果,即所有小部件都从底部开始:

最佳答案

用 Scaffold 包裹您的 ListView 并设置 resizeToAvoidBottomInset: true,此属性。也许这可以帮助你。

https://stackoverflow.com/questions/48067818/

相关文章:

android - 如何从我的 Flutter 应用程序控制网络缓存?

google-maps - 如何在 flutter 中更改谷歌地图 API 我的位置按钮位置?

json - 如何在 Dart 中使用带有 json 序列化的泛型和泛型列表?

java - java中是否有以下Aes加密函数的Dart等价物

android-studio - Flutter/Dart 自动完成功能适用于 VS Code,但不

flutter - 相对定位小部件

flutter - 如何使图像的 1/3 占据全屏

dart - 防止滚动的英雄跳到应用栏顶部

flutter - 需要不同屏幕纵横比和纵向和横向模式的聊天屏幕背景图片

javascript - 在 Flutter Webview 中运行一些 Javascript 文件