-1

While editing my textfield the keyboard hide half the screen. I want to make the screen push up with the keyboard so I can see all the field. How do I do it?

Before tap to a textfield After tap to a textfield

Here my widget form, I have already tried SingleScrollView but the problem is my view turned all white

class SignUpFormState extends State<_SignUpForm> {
  final _signUpFormKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return Consumer<LoginModel>(
        builder: (context, loginModel, child) => Expanded(
              child: Padding(
                padding: EdgeInsets.only(left: 16.0, right: 16.0),
                child: Card(
                  child: Form(
                      key: _signUpFormKey,
                      child: Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 16.0),
                        child: Column(
                          children: <Widget>[
                            Container( height: 16.0,),
                            Text(),
                            Spacer(flex: 3, ),
                            Padding(),
                            Padding(),
                            Padding(),
                            Padding(),
                            Spacer( flex: 4,),
                            Row(),
                          ],
                        ),
                      )),
                ),
              ),
            ));
  }
}

3 Answers3

2

Use SingleChildView likes this.

class SomeWidgetState extends State<SomeWidget> {
  @override
  Widget build(BuildContext context) {
    //If you use Scaffold in parent widget, use Container instead of Scaffold.
    return Scaffold(
      body: SingleChildScrollView(
        child: Column([Your Login Form Widget])
    )
  }
}
0

Use Scaffold as the root and add resizeToAvoidBottomPadding: false, just before the end of scaffold bracket. You'll be good to go.

example:

return Scaffold(
      body: Column(
        .....


      ),


 resizeToAvoidBottomPadding: false, //this line here

    );
sfung3
  • 2,227
  • 1
  • 9
  • 30
Fahad Hussain
  • 185
  • 1
  • 3
  • 15
-1

Use Scaffold widget as the root of the screen. Problem will be solved.

For example :

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: ListView(  // or Column
      // contents
    )
  );
}
Newaj
  • 3,992
  • 4
  • 32
  • 50
  • Without Scaffold, this screen is not visible. means, he is already using Scaffold. He need to wrap body in SingleChildScrollView() – Mateen Mar 04 '20 at 09:03
  • I meant root of this screen. – Newaj Mar 04 '20 at 09:05
  • @AR , See, the problem is - TextField goes under keyboard. Using Scaffold, can solve this. I hope you'll reconsider your downvote. – Newaj Mar 04 '20 at 09:15
  • Screen designed by the user is static right now, that screen width and height will be different in different mobile. So he needed flexibility to scroll if contents are more than current screen size. Issue on Keyboard opening, anything you are entering your textfield should appear on screen. So if it isn't appearing it will gives error. by using SingleChildScrollView(), it will gives you flexibility to scroll up a little so textfield will viewable. @AR you have to consider your downvote – Mateen Mar 04 '20 at 09:16