Member-only story
A Better Way To Create Flutter Data Classes
The easiest way to get rid of legacy we do not need is to combine the id feature of entity with the necessity of needing immutable value object types as a data class…
Immutable data classes are the preferred way to model an application API in flutter. In this article, I describe what data classes are and show how to create them.
Getting Rid Of Legacy
Back when both Domain Driven Design and Clean Architecture were created applications we were still using SQL which is where the main thrust of the entity class and such things as CQRS(CQRS in simple terms is a command event set up with writes and reads separated) come from. In the present environments of using no-SQL or graphQL we no longer have the need for full entity and no need to separate out the reads and writes.
Hence, the trend in several frameworks including Flutter of combining the ID feature of the entity class with feaures of an immutable data class into one class. But, before we get to implement the data class we have to implement value objects and validation as that provides not only immutable fields of the data class making the data class immutable but also provides as way to inject some smart logic into the model.