3. Experience Freezed

Overview

In Dart and Flutter, appropriate manipulation of data entities involves ensuring that they implement an “abstract data type” (ADT). In practical terms, it means that:

Implementing all of this manually is a hassle, and generally requires dozens to hundreds of lines of boilerplate code which is easy to get wrong and can create very subtle bugs.

The Flutter “industry standard” for creating abstract data types is Freezed. It is a code generation facility, where you provide a kind of “top-level specification” of your data entity, run a command line script, and the Freezed package generates all of the code necessary for make your entity a true ADT.

There is a very small learning curve associated with Freezed, but it’s really not very complicated and the results are definitely worth the investment in time to learn it.

In this experience, you will read up on Freezed and then test your understanding by porting a couple of data types to use Freezed.

Tasks

Background readings

To begin, please read all of the Readings in this module labeled “Freezed”. You should also download and run the Flutter_Riverpod_Freezed sample app, which provides working samples of the use of Freezed to create data model entities. (It also illustrates how to use Dio to retrieve data from an external API, which is pretty sweet.)

Once you feel somewhat comfortable with Freezed, it’s time to test your understanding.

Update the Starter Architecture’s Entry and Job to use Freezed

In the last experience, you made a personal fork of the starter_architecture_flutter_firebase repo.

For this experience, please create a branch in your fork called “freezed”, and then update the code for the Entry and Job data model classes to use Freezed rather than Equatable.

Here are some tips:

Submission Instructions

By the date and time listed in the Schedule page, please upload the URL to your github repo containing this branch to Laulima.