How to add a placeholder text into TextField or TextFormField

This Article is posted by seven.srikanth at 28-07-2018 04:57:19

In flutter you have two different types of text fields, TextField and TextFormField.
Inorder to get a Text inside the TextFIeld or TextFormField, you need to modify your code as below.
For TextField,
TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Please enter a search term'
),
),
For TextFormField,
 
TextFormField(
decoration: InputDecoration(
hintText: "First Name"
),
validator: (value) {
if(value.isEmpty) {
return 'Please enter some text';
}
},
),
Hope this is helpful.

Tags: How to add a placeholder text into TextField or TextFormField in Flutter;



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.



Recent Articles


How to add Assets Images and Network images in flutter?

Posted by bloggeraatit on 20 Sep 2019 Article


How to use inkwell class for responding images in flutter?

Posted by bloggeraatit on 20 Sep 2019 Article


Flutter Web Live on Server

Posted by nikhilchaudhary12155 on 18 Sep 2019 Article


How to specify stops in a gradient?

Posted by seven.srikanth on 20 Sep 2019 Article



© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com