DEV Community

tkpranav
tkpranav

Posted on • Originally published at Medium on

How To Validate Forms In Flutter.?

NEED:

To show that something is wrong with the submitted data, we use form validation.

Widgets Used:

  1. Form

  2. TextFormField

Lets go to the Steps:

STEP 1:

Inside your project, add a Scaffold with a Floating Action Button.

We use this button to submit and validate the form.

STEP 2:

Add a Form widget to the body of the Scaffold.Give a global key to this form to validate it from anywhere.

After that, add two TextFormField’s to the form.

STEP 3 :

Apply decoration and onChanged method to these Text Form Fields.

Then add the validator, which will validate the submitted string.

STEP 4 :

At last, when we press the FAB , we need to validate the form.

So, inside OnPressed method of FAB, carryout the validation of the form.

And DONE ..!


Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay