Search code examples
flutterdartstylesalignmenttextformfield

The alignment of a TextFormField validation error message


How can I change the alignment of a TextFormField validation error message?

TextFormField(
   textAlign: TextAlign.center,
   decoration: const InputDecoration(
      errorStyle: TextStyle(
        fontSize: 16.0,
      ),
   ),
   validator: (value) {
      if (value.isEmpty) {
         return 'Please enter some text';
      }
      return null;
    },
   ),

Current output:

enter image description here

Expected output:

enter image description here


Solution

  • You can't change the default validator, but try creating a custom one!

    Custom Validation TextFormField Flutter