2

I have a layout with two TextField and I am worried about all the items being resized when the keyboard is shown.

The layouts with and without the keyboard are in the picture below.

layout without keyboardlayout with keyboard

When the keyboard is shown all the widgets (TextField Text and Button) resize to the top.

As my widgets are wrapped into a SingleChildScrollView, even if the screen is small we can scroll to see all the items, therefore, there isn't a problem.

Widget _buildCamposLogin() {
  return Form(
    key: _formKey,
    child: Container(
      margin: EdgeInsets.only(bottom: 50.0, left: 30.0, right: 30.0),
      child: SingleChildScrollView(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            _buildLoginText(),
            _buildCampoCPF(),
            _buildCampoSenha(),
            _buildSubmitButton(),
            _buildCadastroText(),
          ],
        ),
      ),
    ),
  );
}

So, the problem is I feel weird about moving everything to the top, shouldn't be better to move only the TextField which was focused and the other things above this TextField, instead of moving everything above and below the TextField which was focused.

If you think this is better, what would be the solution to move only the TextField and widgets above to the top?

Why my question is not duplicated

In the marked question, the guy asks how to prevent the keyboard from moving the widgets. And the answers say to set resizeToAvoidBottomInset: false in the Scaffold. That's is completely different from what I am asking.

I do want the keyboard to move the widgets to the top as it does. The problem is that it moves all my widgets, the 2 TextField the RaisedButton and the 2 Text at the bottom. I would like to move only the TextField which was shown as the following example.

Note the difference between these two pictures below and the others I've already uploaded.

Layout I desire without keyboardLayout I desire with keyboard

Soon Santos
  • 2,107
  • 22
  • 43
  • 1
    Possible duplicate of [When the keyboard appears, the Flutter widgets resize. How to prevent this?](https://stackoverflow.com/questions/46551268/when-the-keyboard-appears-the-flutter-widgets-resize-how-to-prevent-this) – Noodles Jul 29 '19 at 22:54

1 Answers1

0

From what I understand to summarize the question, you're looking to retain the size the background elements on the Screen. Preventing the background to be resized when the softkeyboard appears.

As mentioned in the comments, the workarounds posted in this question seems applicable to your use case. The Scaffold.resizeToAvoidBottomInset can be set to false to prevent resizing when the keyboard appears.

Omatt
  • 8,564
  • 2
  • 42
  • 144