Skip to content Skip to sidebar Skip to footer

How To Avoid Full Page Reloading When Keyboard Pops Up?

Check out this video for problem demo https://youtu.be/GsdWcTEbUbg As there is a large number of code, I will try to summarize the structure of the code here. In a nutshell: Scaffo

Solution 1:

As one of the links you provides points out your buildmethod fires whenever the state of the app changes i.e the keyboard pops up, so move the streambuilder outside of it. There are a few more changes you could do. Try the following,

create a variable outside of the build method.

var myStreamBuilder;
//....//inside initialstate method
     myStreamBuilder = StreamBuilder<dynamic>(
            stream: globals.chatRoomBloc.threadScreen,
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              return Column(
                crossAxisAlignment:
                    CrossAxisAlignment.stretch, // sticks to the keyboard
                children: <Widget>[
                  Expanded(
                    child: Scrollbar(
                      child: ListView.builder(
                        shrinkWrap: true,
                        itemCount: list.length,
                        itemBuilder: (BuildContext context, int index) {
                          return TileWidget();
                        },
                      ),
                    ),
                  ),
                ],
              );
            },
          ),

Then in your build method call the variable.

Scaffold(
  appBar: AppBar(),
  resizeToAvoidBottomInset: false, //don't forget this!body: myStreamBuilder
)

EDIT: Make sure you check your snapshot that it hasData or not. If there is no data then something should be returned until it does have data, this way the user is informed what the app is doing.

Also this property might also be helpful to you. resizeToAvoidBottomInset - https://api.flutter.dev/flutter/material/Scaffold/resizeToAvoidBottomInset.html

Post a Comment for "How To Avoid Full Page Reloading When Keyboard Pops Up?"