Set TextField Hint Text Alignment Vertically Center in Flutter

Hello friends, When I was working on my previous tutorial then I had noticed a thing in TextField widget. The thing is that by default when we apply Border on TextField widget then the Hint vertically alignement is not right that time and even the entered text alignment is incorrect. This looks inappropriate a viewer. So this can be fixed by using contentPadding property of InputDecoration. All we have to do is apply contentPadding on our TextField widget and it looks fine. So in this tutorial we would learn about Set TextField Hint Text Alignment Vertically Center in Flutter.

Screenshot without setting up vertical alignment using contentPadding :-

Screenshot after applying contentPadding :-

Set TextField Hint Text Alignment Vertically Center in FlutterContents in this project Set TextField Hint Text Alignment Vertically Center in Flutter :-

1. Open your project’s main.dart file and import material.dart package.

2. Creating our main runApp() method, Here we would call our main MyApp class.

3. Creating our main MyApp extends StatelessWidget.

4. Creating our main TextField widget. Here we would apply the contentPadding: EdgeInsets.fromLTRB(10, 0, 0, 0),. This would the padding from Left side to 10 pixels and Zero from Top, bottom and right side.

5. Complete source code for main.dart file :-

Screenshot :-

Set TextField Hint Text Alignment Vertically Center in Flutter

Leave a Reply

Your email address will not be published. Required fields are marked *