chore(wip): upgrade dependencies, begin refactor
This commit is contained in:
24
frontend/lib/domain/README.md
Normal file
24
frontend/lib/domain/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Domain layer
|
||||
|
||||
## `entities` - Model definition
|
||||
|
||||
Since we follow the repository structure convention, in this folder we purely define data models, without providing any logic. To reduce boilerplate, we use the `freezed` package. This requires some code generation, which means that all model definitions have the following structure:
|
||||
```dart
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
// required: associates our `main.dart` with the code generated by Freezed
|
||||
part 'main.freezed.dart';
|
||||
// optional: Since our Person class is serializable, we must add this line.
|
||||
// But if Person was not serializable, we could skip it.
|
||||
part 'main.g.dart';
|
||||
```
|
||||
|
||||
This is required boilerplate for all models. Then, we define the model itself using the `@freezed` annotation:
|
||||
```dart
|
||||
@freezed
|
||||
...
|
||||
```
|
||||
|
||||
The `*.frozen.dart` and `*.g.dart` are pure boilerplate and should not be touched.
|
||||
|
||||
Note that the description of the data will losely follow the capabilities of the backend but does not need to reflect it exactly. That is where the `data` part is for: translating api calls into flutter objects.
|
||||
Reference in New Issue
Block a user