Skip to main content
Logo Appt Light

Input errors on Flutter

Users should be notified when they make input errors. Show a clear error message when data has been entered incorrectly. Furthermore, provide suggestions that help users to fix the error. It is important that error messages are also posted to users of assistive technologies.

With Flutter, you can set an InputDecoration on a TextField to indicate an error. Set the errorText property to the error message that should be displayed. To remove the error, set the errorText to null. The error message should also be posted to assistive technologies by using an accessibility announcement.

bool _hasError = false;

TextField(
  decoration: InputDecoration(
    labelText: 'Date of birth',
    helperText: _hasError ? 'Invalid date, must be in the form DD/MM/YYYY, for example, 01/01/2000' : null,
  ),
);

Feedback?

Let us know!