Designing an n-tier architecture, part 3 – services
The final tier that we will be talking about in this exploration of the n-tier architecture is the services tier. This tier serves as the glue between the controllers and repositories. Its primary job is to transform the data from the generic format used by the storage solution into the actual schema that is used by the controllers and the user interface.
In this recipe, we will be creating serialization and deserialization functions for our models, as well as stitching it all together with a services class.
How to do it...
This recipe will be divided into two components – serialization and integration. We're going to start with the serialization functions and then snap together all the pieces that we built over the last three recipes:
- Open
task.dart
and add anid
property and a default constructor. This will allow theTask
model to be transformed into a genericModel
:
import 'package:flutter/foundation.dart...