You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scroll text fields into view when keyboard comes up and obscures them #10826
I have several TextFormFields in a ListView, and it seems that if I tap into fields near the bottom (fields that would be obscured by the keyboard), the keyboard will appear and then immediately hide. I’m guessing it’s because it’s scrolling the list view which then causes the keyboard to dismiss. I've modified the flutter gallery text field demo and attached a video. Happens on both iOS and Android.
changed the title [-]Tapping into TextFormFields inside ListView cause keyboard to show and immediately hide[/-][+]Tapping into TextFormFields inside ListView causes keyboard to show and immediately hide[/+]on Jun 19, 2017
Not really. Mark it a blocker and I'll fix it in the next week or two. (I'm working on deep linking bugs right now, which I understand are also a high priority.)
new ListView(
reverse: true,
children: <Widget>[
// put your text fields here
].reversed.toList(),
),
This is inspired by how the Flutter UI codelab works (we want to use the bottom of the ListView as the scroll anchor instead of the top, so that the software keyboard will shift the list contents upwards).
Unfortunately, it can introduce a new bug if the scrolling pushes the text fields upwards and they end up getting hidden by the top. If you only have a few text fields and they're at the bottom of your ListView, this might be just fine, but it would still be a problem if you have a lot of text fields.
Reacted by amaan75, Niklas, matejthetree, Manuel Rodríguez-Sánchez, Harsh Sharma, Bartlomiej Tartanus, Oops, Vagner Santos, guediagael, elfico and 17 more
Reacted by Kalyani Ghumare, Ahmed Mokhtar, Houston and isorensen
Reacted by Niklas, Oops, Vagner Santos, Sipatha Shoko, Riddhi Shankar, SergioOrellanaR, Kanit, m8811163008 and philippearmel
Reacted by AbdulRahman Mansy, Sergei Mikhailovskii, HappyBhalodiya, Hewa Jalal and Houston
You can use a SingleChildScrollView with a Column instead of a ListView to prevent the keyboard from dismissing. It won't solve the problem of the text field being hidden by the keyboard, but it would at least allow the user to scroll the field into view and then fill it out.
Reacted by Krishnakumar R, Willy Hystor and Niroj Shrestha
Thanks @collinjackson . The SingleChildScrollView workaround makes my form useable. The fix would be great so that the text fields aren't hidden requiring the user to scroll the field into view.
@Hixie is going to work on preventing fields from being scrolled offscreen by the keyboard as part of his work on #105 next week. Once that is done, we can close this bug and you'll be able to go back to using ListView.
I've a patch that does almost all of this. The two remaining bits are actually scrolling the text field into view, and handling text fields that have decorations because the reparenting is causing some sort of bug in my code and prematurely ejecting the row.
You can use a SingleChildScrollView with a Column instead of a ListView to prevent the keyboard from dismissing. It won't solve the problem of the text field being hidden by the keyboard, but it would at least allow the user to scroll the field into view and then fill it out.
Thank You Brother. you solved my problem i had the issue like my error messages are gone, i have more form fields in form after clicking button i showing error to user, after scrolling to down and scroll upwards my errors are missing.
My Error widget tree:
Form -> Listview
Correct widget tree:
Form -> SingleChildScrollView -> Column
In my case I realized when I had windowFullscreen style attribute of the LaunchTheme set to true <item name="android:windowFullscreen">true</item>, SystemChrome.* methods did not work. These methods started working as expected when I set it to false.
Don't know if this is still an issue, but it was for me today with the stable sdk branch. I noticed that the SingleChildScrollView was moving when the text field was being focused and almost outside of the viewport. So I thought that maybe the keyboard height was missing to the scrolling position. And indeed it was, I added the text field the property scrollPadding with the bottom view inset size and it worked like charm (MediaQuery.of(context).viewInsets.bottom). Hope it helps.
@hazzo Can you explain with little code please?
Because I'm having the same issue with keyboard hide TextField when pop up and I have tried every single solution exists here and in stackoverflow but no luck.
The problem is what the hell is wrong with the code
SingleChildScrollView, ListView , Column combination but no luck
Thankx @hazzo but unfortunately it didn't work. But my code worked fine after little investigating about the problem cause.
please refer to this 64392#issuecomment-678997571 for more details
new ListView(
reverse: true,
children: <Widget>[
// put your text fields here
].reversed.toList(),
),
This is inspired by how the Flutter UI codelab works (we want to use the bottom of the ListView as the scroll anchor instead of the top, so that the software keyboard will shift the list contents upwards).
Unfortunately, it can introduce a new bug if the scrolling pushes the text fields upwards and they end up getting hidden by the top. If you only have a few text fields and they're at the bottom of your ListView, this might be just fine, but it would still be a problem if you have a lot of text fields.
Thank you for posting your reply @collinjackson. I had the same problem. However, I was using ListView.builder, so it wasn't just like you did, but this workaround worked for me:
ListView.builder(
reverse: true, // <====== ADDED THIS
itemCount: tasks.length,
itemBuilder: (context, index) {
index = (index - tasks.length).abs(); // <====== ADDED THIS
// Keep same code as before
},
...
);
This worked just fine, kept the list in same order. However need to do a +1 in the index reassignment to handle out of index. index = (index + 1 - tasks.length).abs()
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
[-]Tapping into TextFormFields inside ListView cause keyboard to show and immediately hide[/-][+]Tapping into TextFormFields inside ListView causes keyboard to show and immediately hide[/+]eseidelGoogle commentedon Jun 19, 2017
@Hixie @abarth this sounds familiar, do we already have this tracked/understood somewhere else?
Hixie commentedon Jun 19, 2017
This is basically the same bug as #105, #170, #172, #188.
eseidelGoogle commentedon Jun 19, 2017
@Hixie is there anything Posse can do to work around this bug? This specific instantiation is currently considered as a high priority issue.
Hixie commentedon Jun 19, 2017
Not really. Mark it a blocker and I'll fix it in the next week or two. (I'm working on deep linking bugs right now, which I understand are also a high priority.)
collinjackson commentedon Jun 21, 2017
There's a workaround that should get around this:
This is inspired by how the Flutter UI codelab works (we want to use the bottom of the
ListViewas the scroll anchor instead of the top, so that the software keyboard will shift the list contents upwards).Unfortunately, it can introduce a new bug if the scrolling pushes the text fields upwards and they end up getting hidden by the top. If you only have a few text fields and they're at the bottom of your
ListView, this might be just fine, but it would still be a problem if you have a lot of text fields.collinjackson commentedon Jun 21, 2017
You can use a
SingleChildScrollViewwith aColumninstead of aListViewto prevent the keyboard from dismissing. It won't solve the problem of the text field being hidden by the keyboard, but it would at least allow the user to scroll the field into view and then fill it out.alardizabal commentedon Jun 21, 2017
Thanks @collinjackson . The SingleChildScrollView workaround makes my form useable. The fix would be great so that the text fields aren't hidden requiring the user to scroll the field into view.
collinjackson commentedon Jun 21, 2017
OK, good. Sounds like it's no longer blocking.
@Hixie is going to work on preventing fields from being scrolled offscreen by the keyboard as part of his work on #105 next week. Once that is done, we can close this bug and you'll be able to go back to using
ListView.Hixie commentedon Jun 27, 2017
I've begun work on this issue.
Hixie commentedon Jul 1, 2017
I've a patch that does almost all of this. The two remaining bits are actually scrolling the text field into view, and handling text fields that have decorations because the reparenting is causing some sort of bug in my code and prematurely ejecting the row.
118 remaining items
Allan-Nava commentedon May 7, 2019
How can I put my form centered and when the keyboard is shown put all up of the keyboard?
msarkrish commentedon Aug 12, 2019
Thank You Brother. you solved my problem i had the issue like my error messages are gone, i have more form fields in form after clicking button i showing error to user, after scrolling to down and scroll upwards my errors are missing.
My Error widget tree:
Form -> Listview
Correct widget tree:
Form -> SingleChildScrollView -> Column
Hassan-Fa commentedon Dec 25, 2019
@acidjazz
not in master yet ?
cause I still have this issue on master
broberts-nybble commentedon Jan 15, 2020
on the latest version, was working without any issues now appears to have returned.
please advise?
edwinnyawoli commentedon May 12, 2020
In my case I realized when I had windowFullscreen style attribute of the
LaunchThemeset to true<item name="android:windowFullscreen">true</item>,SystemChrome.*methods did not work. These methods started working as expected when I set it to false.QasimQuaid commentedon Aug 11, 2020
Any update?
hazzo commentedon Aug 12, 2020
Don't know if this is still an issue, but it was for me today with the stable sdk branch. I noticed that the
SingleChildScrollViewwas moving when the text field was being focused and almost outside of the viewport. So I thought that maybe the keyboard height was missing to the scrolling position. And indeed it was, I added the text field the propertyscrollPaddingwith the bottom view inset size and it worked like charm (MediaQuery.of(context).viewInsets.bottom). Hope it helps.Blacktoviche commentedon Aug 22, 2020
@hazzo Can you explain with little code please?
Because I'm having the same issue with keyboard hide TextField when pop up and I have tried every single solution exists here and in stackoverflow but no luck.
The problem is what the hell is wrong with the code
SingleChildScrollView, ListView , Column combination but no luck
hazzo commentedon Aug 23, 2020
@Blacktoviche something like this should do the trick:
Blacktoviche commentedon Aug 24, 2020
Thankx @hazzo but unfortunately it didn't work. But my code worked fine after little investigating about the problem cause.
please refer to this 64392#issuecomment-678997571 for more details
lionuncle commentedon Jan 20, 2021
Wrap your widget inside
Scaffoldand setresizeToAvoidBottomInset: true,adekunleba commentedon Apr 10, 2021
This worked just fine, kept the list in same order. However need to do a
+1in the index reassignment to handle out of index.index = (index + 1 - tasks.length).abs()github-actions commentedon Aug 3, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.