textformfield flutter code example

Example 1: text field flutter

TextField(
              onChanged: (value) {
                //Do something with the user input.
              },
              decoration: InputDecoration(
                hintText: 'Enter your password.',
                contentPadding:
                    EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.all(Radius.circular(32.0)),
                ),
                enabledBorder: OutlineInputBorder(
                  borderSide:
                      BorderSide(color: Colors.lightBlueAccent, width: 1.0),
                  borderRadius: BorderRadius.all(Radius.circular(32.0)),
                ),
                focusedBorder: OutlineInputBorder(
                  borderSide:
                      BorderSide(color: Colors.lightBlueAccent, width: 2.0),
                  borderRadius: BorderRadius.all(Radius.circular(32.0)),
                ),
              ),
            ),

Example 2: text input validation message color flutter

TextFormField(
  decoration: InputDecoration(
     errorStyle: TextStyle(
      color: Colors.red[400],
      fontWeight: FontWeight.bold,
      fontSize: 13,
    ),
  ),
  ...
)

Example 3: flutter text field form

TextField(
  decoration: InputDecoration(
    border: InputBorder.none,
    hintText: 'Enter a search term'
  ),
);

Example 4: text form field flutter

TextFormField(
  decoration: InputDecoration(
    labelText: 'Enter your username'
  ),
);

Example 5: textfield set value flutter

/// You can use a [TextFormField] instead of [TextField]
/// and use the [initialValue] property. for example:

TextFormField(initialValue: "I am smart")

Tags:

Dart Example