Flutter Formz Explained — The Complete Crash Course

Tomic Riedel
4 min readApr 20, 2024

Formz is a Dart package developed by Very Good Ventures to simplify form representation and validation in Dart applications. This package provides a unified form representation that makes it easier to manage both the data of form fields as well as their validation status.

Once you fully understand how to use it, you never want to miss it again.

And because of that, we are going to take a deep look at Formz today!

Let’s get started!

Installation

The first thing we have to do after creating our app is to add formz. To do so, we will use the command flutter pub add formz. The version of formz when writing this article is 0.7.0, but it’s quite likely that this tutorial will also work if you use a higher version because the basics won’t change.

Create a Formz Module

Formz is structured into models, where each module validates different things. E.g., a module can be used to validate an email address, password, or date. It looks like this:

import 'package:formz/formz.dart';

// This represents all of the wrong states or field can have.
// A password can be too short, does not have any digit or uppercase letter.
enum PasswordInputError { tooShort, noDigit…

--

--

Tomic Riedel

Sharing the process of building a portfolio of apps to make people more productive.