Flutter Set PlaceHolder Hint Text Alignment Center in TextField

The default Hint alignment is Left in TextField widget in flutter. But flutter gives us facility to change Alignment in 6 different directions Center, End, Left, Right, Justify and Start. Application developer can change TextField inside text align using textAlign prop with 6 different properties. So in this tutorial we would Flutter Set PlaceHolder Hint Text Alignment Center in TextField Android iOS Example Tutorial.

Contents in this project Flutter Set PlaceHolder Hint Text Alignment Center in TextField Android iOS Example Tutorial:

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

2. Creating void main runApp() method and here we would call our main MyApp class.

3. Creating our main MyApp class extends State less widget. This is our main Root class.

4. Creating Widget Build Area -> Material App Widget -> Scaffold Widget -> Safe Area Widget -> Center Widget -> Container Widget.

5. Creating TextField Widget in Container Widget as Child.

  • textAlign : TextAlign.center is used to Align the Hint Text in Center of Text Field widget.

6. Complete source code for main.dart file:

Screenshot:

Flutter Set PlaceHolder Hint Text Alignment Center in TextField

Flutter Set PlaceHolder Hint Text Alignment Center in TextField

Leave a Reply

Your email address will not be published.