2

I have this code for a chat app that renders a series of messages. The thing is page is showing ok, but when trying to send a message rendering overflow appears. It's like my input is going all the way up instead of setting itself over my displayed keyboard.

This is my code for rendering the page

 return Scaffold(
  body: Column(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      Flexible(
        child: ListView.builder(
          itemBuilder: (_, index) => _messages[index],
          itemCount: _messages.length,
          //El reverse hace que vaya de abajo hacia arriba
          reverse: true,
          padding: EdgeInsets.all(6.0),
        ),
      ),
      Divider(
        height: 1.0,
      ),
      Container(
        child: _buildComposer(),
        decoration: BoxDecoration(color: Theme.of(context).cardColor),
      )
    ],
  ),
);

And here I have my code for the input where think the mistake is

 Widget _buildComposer() {
return IconTheme(
  data: IconThemeData(color: Theme.of(context).accentColor),
  child: Container(
    margin: const EdgeInsets.symmetric(horizontal: 9.0),
    child: Row(
     // mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Flexible(
          child: TextField(
            controller: _textController,
            onChanged: (String texto) {
              setState(() {
                _isWriting = texto.length > 0;
              });
            },
            onSubmitted: _enviarMensaje,
            decoration:
                InputDecoration.collapsed(hintText: "Envie un mensaje!"),
          ),
        ),
        Container(
          margin: EdgeInsets.symmetric(horizontal: 3.0),
          child: IconButton(
            icon: Icon(Icons.message),
            onPressed: _isWriting
                ? () => _enviarMensaje(_textController.text)
                : null,
          ),
        )
      ],
    ),
  ),
);

}

Here are my print captures for initial rendering, after clicking inside the input to write some message

enter image description here

enter image description here

Here's my log, and it's supposed to be easy to understand the approach I should take but I'm not having any luck with it.

enter image description here FYI: I have already tried this approach but did not seem to work StackOverflow answer on rendering

I have already gone through flutter.io docs but I'm not understanding the whole listview theory. If you have some insights I would appreciate them as well so I can deeply understand how it behaves.

G H Prakash
  • 1,720
  • 10
  • 30
Matias
  • 708
  • 10
  • 24

1 Answers1

1

resizeToAvoidBottomPadding: false might help.. have a look here

As @diegoveloper's comment, it will not resize which means it will not show content behind keyboard. Based on your use case you can choose option 1 or 2 in the above link

Dinesh Balasubramanian
  • 20,532
  • 7
  • 64
  • 57