Flutter Forms Validation — the Ultimate Guide

Rap Payne
Flutter Community
Published in
13 min readOct 24, 2020

--

You’ve joined an innovative new company called Prestige Worldwide to create their app using Flutter. It’s a great app that lets your users register with their email address and password. You release the app to great fanfare, it goes viral and 10,000 people register on day one.

Fortune and fame await you! Sounds good so far? Not so fast, cowboy.

It turns out that half of your users gave you email addresses like “none of your business” and “you can’t have my email”. The other half have passwords so weak they’re bound to be cracked within a day or two, exposing Prestige Worldwide to fraud.

Alas! If only you’d put data validation into your forms, your reputation and bank balance would’ve been safe.

In this tutorial, you’ll learn:

  • How to implement validations without a form.
  • How to implement validations with a form.
  • How to implement validations on non-textfields.
  • How to autovalidate forms on user input.
  • How to control form flow with FocusNodes.

Note: This tutorial assumes you’re already be familiar with Flutter development. If you’re new to Fluter, clap for this article, then take a look at this awesome list, watch one of the Flutter team’s videos here, or pick up my Flutter intro book. Hope these help you get started.

Getting Started

--

--

Rap Payne
Flutter Community

Twitter: @Rap_Payne. Mobile and Web app developer. Consultant, trainer, author of “Beginning App Development with Flutter” (http://bit.ly/flutter_book).