Member-only story

Do Not Do Naked Failure Antipattern

Fred Grott
5 min readFeb 12, 2022

--

Naked failure classes in your Flutter App is an antipattern, as it hides the app error from any handling effort; and it also hides your effort to resolve it from the flutter app user. Let me show you how.

Freezed vs Equatable

How do we tell when to use Freezed and when to use Equatable for a value object? A simple value object just maps to one specific value object type. But what happens if we need the value object to map to different value object types?

What I am talking about is a Value Object that returns a subtype. We can return a subtype via a factory method.

Thus, instead of the simple value objects that equatable creates, we have to use Freezed to create a complex value object that can map factories to Value Object subtypes.

Let me show the Exceptions subtypes first:

And those exceptions can normally be used just like we did before with exceptions, i.e. the throw statement. But, now we are going to integrate it into our Domain-Driven Design architecture by allowing ti to be…

--

--

Fred Grott
Fred Grott

No responses yet