I have an app that shows textfields and image and I face a problem when the user tries to enter data in textfield as the keyboard goes up and cover the entire textfields.
I tried to use SingleChildScrollView but it is not practical as the textfields do not go up automatically but the user has to scroll up by himself.
Here is the code:
Try using Animation and move up your text field when keyboard appears. Check this out When i select a Textfield the keyboard moves over it
Don't have a sized container inside, follow the below :
SingleChildScrollView(
child: Stack(
children: <Widget>[
... your code
]
)
)
In your Scaffold, set resizeToAvoidBottomPadding property to false.
Related
I have an app that has multiple textfields and a button that analyze the data entered.
When I fill the textfields, the keyboard pops up and hide the button.
I want the app to slide up completely away from the keyboard.
FYI: resizeToAvoidBottomInset is set to true, and the main column is wrapped in singlechildview.
Button shown
Button hidden by keyboard
Just add this Property in SinglechildScrollview:
reverse: true
It will solve your problem.
Whenever I tap on Textfield it shows me this white container. How do I remove that?
You need to wrap everything in a SingleChildScrollView and set the reverse to true.
SingleChildScrollView(
reverse: true,
child: Container(),
);
On iOS, tapping the status bar makes PrimaryScrollController go to the top:
https://flutter.dev/docs/resources/platform-adaptations#return-to-top
On iOS, tapping the OS status bar scrolls the primary scroll controller to the top position. There is no equivalent behavior on Android.
My PrimaryScrollController is attached to a ListView with reverse:true, so tapping the status bar makes it scroll to the bottom.
Docs say PrimaryScrollView handles ScrollAction if not handled by another scroll controller.
https://api.flutter.dev/flutter/widgets/PrimaryScrollController-class.html
If a ScrollAction is not handled by an otherwise focused part of the application, the ScrollAction will be evaluated using the scroll view associated with a PrimaryScrollController
How can I handle scroll actions myself so I can reverse the direction PrimaryScrollController goes when the status bar is tapped?
The easiest way to accomplish this is likely going to be reversing the items in your list instead of using the reverse: true flag of ListView.
For example:
ListView(
children: [
Container(),
Container(),
].reversed.toList(),
),
Trying to solve this any other way would get pretty involved. Since we don't have access to the StatusBar we can't override its behavior or listen for taps on it.
When the keyboard is previously dismissed and i click on a TextField, the keyboard is toggled and this TextField is focused. However the keyboard is blocking the below TextFields, and it requires either a manual scroll from the user, or a textInputAction: TextInputAction.next to reach the next TextField.
Is there a way to show the most TextFields possible, without requiring a controller to control the scrolling behavior.
Note: In my widget tree i have
body: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: Column(
children: [ ...
Here is a view of the issue : https://i.stack.imgur.com/YiZ9w.gif
Thanks for your help
I have two Pages inside a vertical PageView.
PageView(
controller: pageController,
scrollDirection: Axis.vertical,
children: [
PageA(),
PageB(),
],
)
The lower page (B) contains the following:
Column
Row
...
Expanded
ListView
Card
Container
Row
...
Flexible
Padding
TextFormField
The problem occurs whenever I focus and unfocus the TextFormField.
Expetation: The Keyboard pops up and the Expanded ListView shrinks, so that the TextFormField is above the Keyboard. When the Keyboard is dismissed, the ListView should expand and the page should look as before.
What happens instead: When the Keyboard is dissmissed, the ListView expands back to its original size but the Page (B) stays offset above where the keyboard was and doesn't move back down. The end result is, that the page (B) is offset upwards ind thus partially offscreen and I have to scroll it manually back down.
The page B itself has a fixed size and once scrolled back down, it can't be offset upwards manually.
TL;DR: PageView pushes page partially off screen after dismissing keyboard.
Any help is apreciated and thanks in advance :D
Edit: Added Screenshot: Before, while and after editing the text field
Edit 2: I think it has something to do with the pageview itself and its scroll physics.