Form field guide for flutter

sourav mandal
1 min readApr 11, 2022

--

Padding(  
padding: EdgeInsets.all(15),
child: TextField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'User Name',
hintText: 'Enter Your Name',
),
),
),
Padding(
padding: EdgeInsets.all(15),
child: TextField(
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Password',
hintText: 'Enter Password',
),
),
),

use suffix/prefix icon in InputDecoration to add.

multiline text field flutter

TextField(
keyboardType: TextInputType.multiline,
minLines: 1,//Normal textInputField will be displayed
maxLines: 5,// when user presses enter it will adapt to it
);

Drop down select flutter

DropdownButton(

// Initial Value
value: dropdownvalue,

// Down Arrow Icon
icon: const Icon(Icons.keyboard_arrow_down),

// Array list of items
items: items.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(items),
);
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (newValue) {
setState(() {
dropdownvalue = newValue!;
});
},
),

check boxes

Checkbox(  
checkColor: Colors.greenAccent,
activeColor: Colors.red,
value: this.valuefirst,
onChanged: (bool? value) {
setState(() {
this.valuefirst = value;
});
},
),
Checkbox(
value: this.valuesecond,
onChanged: (bool? value) {
setState(() {
this.valuesecond = value;
});
},
),

Switch

Switch(
onChanged: (value) {
_futureDateToggle = value;
},
value: _futureDateToggle,
)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

sourav mandal
sourav mandal

Written by sourav mandal

just a coder who forgets things so makes blogs so he can remember later

No responses yet

Write a response