当键盘出现时,Flutter窗口小部件将调整大小.如何预防呢? [英] When the keyboard appears, the Flutter widgets resize. How to prevent this?

查看:474
本文介绍了当键盘出现时,Flutter窗口小部件将调整大小.如何预防呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列这样的扩展窗口小部件:

I have a Column of Expanded widgets like this:

 return new Container(
      child: new Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          new Expanded(
            flex: 1,
            child: convertFrom,
          ),
          new Expanded(
            flex: 1,
            child: convertTo,
          ),
          new Expanded(
            flex: 1,
            child: description,
          ),
        ],
      ),
    );

它看起来像这样:

convertFrom,包括一个TextField.当我点击此文本字段时,Android键盘将出现在屏幕上.这会更改屏幕尺寸,因此小部件的尺寸应如下调整:

convertFrom, includes a TextField. When I tap on this text field, the Android keyboard appears on the screen. This changes the screen size, so the widgets resize like this:

有没有一种方法可以使键盘覆盖"屏幕,以使专栏"不调整大小?如果我不使用Expanded窗口小部件并为每个窗口小部件硬编码高度,则这些窗口小部件不会调整大小,但是出现键盘时会出现黑色和黄色条纹错误(因为没有足够的空间).对于所有屏幕尺寸,这也不是很灵活.

Is there a way to have the keyboard "overlay" the screen so that my Column doesn't resize? If I don't use Expanded widgets and hardcode a height for each widget, the widgets don't resize, but I get the black-and-yellow striped error when the keyboard appears (because there isn't enough space). This also isn't flexible for all screen sizes.

我不确定这是Android专用还是Flutter专用.

I'm not sure if this is an Android-specific or Flutter-specific.

推荐答案

在您的Scaffold中,将resizeToAvoidBottomInset属性设置为false.

In your Scaffold, set resizeToAvoidBottomInset property to false.

现在不推荐使用属性"resizeToAvoidBottomPadding".... 在您的Scaffold中,将resizeToAvoidBottomPadding属性设置为false.

Property "resizeToAvoidBottomPadding" is deprecated now.... In your Scaffold, set resizeToAvoidBottomPadding property to false.

这篇关于当键盘出现时,Flutter窗口小部件将调整大小.如何预防呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆