-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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 can I align a TextFormField on AppBar in vertical center? #23910
Comments
You can center the textfield giving a padding to your InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 15.0),
... And you can't remove the left/right padding because you are using the title property from What you can do is remove the suffixIcon from your appBar: AppBar(
// automaticallyImplyLeading: false,
actions: <Widget>[
GestureDetector(
onTap: Feedback.wrapForTap(
_textController.clear,
context,
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.clear, color: Colors.white),
),
)
], |
@jaggerwang |
It's worked! |
It works but it's not flexible. If the appbar height changes, the input won't be properly aligned. I tried for hours to do this seemingly simple thing - just place TextField as AppBar title and center it vertically and failed... I tried all possible combinations of Rows Columns Expands Flexibles etc... and none of this worked. I really don't like this solution with hardcoded padding. Is there better solution with Flex or the Flutter is just so awkward that it makes it impossible? |
Also I have set a custom font size in the TextField so the padding is not 15.0 anymore... its not even a whole number and I have to guess it. Very ugly practice :/ |
@JohnnyDevX Did you find a solution for alignment with custom height appbar? |
The preferred size is given then the app bar title not aligned in the vertical center |
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 |
Problem
The
TextFormField
on AppBar is a little higher than the back button on AppBar, and having space on left and right. As the following screenshot shows.I want to align vertical center and removing the left and right space, to simulate a search bar.
Code
The text was updated successfully, but these errors were encountered: