I have chat window in Flutter app.
Messages are presented as widgets inside ListView
widget and I also have widget for message input attached to bottom of the window.
I want to
- hide keyboard when I scroll the
ListView
- scroll to last message when new is added from
InputWidget
code:
class _MessagesPageState extends State<MessagesPage> {
final ScrollController listScrollController = ScrollController();
@override
Widget build(BuildContext context) {
return Scaffold(
....
body: Stack(
children: [
ListView.builder(
controller: listScrollController
....
),
InputWidget()]
);
}
class InputWidget extends StatelessWidget {
final TextEditingController _textEditingController = TextEditingController();
....
Row (
children: [
TextField(
controller: _textEditingController
),
IconButton(icon: ...., onPressed: (){})
]
)}