Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent keyboard from covering an input field #55

Closed
abhinavc opened this issue May 13, 2019 · 3 comments
Closed

How to prevent keyboard from covering an input field #55

abhinavc opened this issue May 13, 2019 · 3 comments

Comments

@abhinavc
Copy link

Hi Danvick,
I am trying to implement the following form structure

Column(
    children: <Widget>[
        someFormBanner(),
        Container( 
             child: FormBuilder(
                key: _globalKey,
                autovalidate: true,
                child: Column(
                   mainAxisSize: MainAxisSize.min,
                   children: <Widget>[
                       FormBuilderTextField( ... ), 
                       FormBuilderTextField( ... ), 
                       FormBuilderTextField( ... ), 
                       FormBuilderTextField( ... ), 
                       FormBuilderTextField( ... ), 
                       FormBuilderTextField( ... ), 
                   ],
                ),
             ),
        ), 
    ], 
)

If I click on a text field lower down, I find that the keyboard covers it

Is there a way to make the focussed field scroll-up above the keyboard?
I have even tried FormBuilder > SingleChildScrollView > Column instead of the above FormBuilder > Column layout. But to no effect

I am hoping I don't have to implement FocusNode etc. and that the solution lies within the
library itself.

Thanks for your help
Abhinav.

@danvick
Copy link
Collaborator

danvick commented May 13, 2019

Hi Anhinav,
First of all, I'd advise you to use SingleChildScrollView so that you don't get overflow issues on smaller devices.

Try setting resizeToAvoidBottomInset flag on your Scaffold to true. This will push up the content of the page when the keyboard shows. Is this the behavior you are expecting?

@abhinavc
Copy link
Author

Hi Danvick,
I didn't have much luck with resizeToAvoidBottomInset: true. It seems it's true by default anyways

However, what seemed to work better was wrapping the form within a Card. In particular, I implemented Scaffold > Card > FormBuilder > ListView as opposed to Scaffold > Column > FormBuilder > Column. It seems that Scaffold by default will roll up a floating widget when the keyboard pops up. And I suppose a Card is a floating widget whereas a Column is not

That said, I'm not sure if what I've done is hack or a valid workaround. Just wanted to share with you anyways

Thanks
Abhinav

@abhinavc
Copy link
Author

My bad. Using Card is not necessarily the solution.

However, I found that using FormBuilder > ListView > <form-fields> worked better for me than
FormBuilder > SingleChildScrollView > Column etc. Can't explain why though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants