Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/cloud_firestore_odm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ flutter pub add --dev cloud_firestore_odm_generator
flutter pub add --dev json_serializable
```

## 5. Enable `create_field_map` of `json_serializable`
## 5. Enable `create_field_map` and `create_per_field_to_json` of `json_serializable`


For the ODM to work, it is necessary to enable the `create_field_map` of `json_serializable`.
For the ODM to work, it is necessary to enable the `create_field_map` and `create_per_field_to_json` of `json_serializable`.
This can be done by creating a `build.yaml` file next to your `pubspec.yaml` and
paste the following:

Expand All @@ -88,15 +88,16 @@ targets:
json_serializable:
options:
create_field_map: true
create_per_field_to_json: true
```


This will enable `create_field_map` for the entire project.
This will enable `create_field_map` and `create_per_field_to_json` for the entire project.

Alternatively, you can enable the option on a per-model basis using `json_annotation`'s `@JsonSerializable` object:

```dart
@JsonSerializable(createFieldMap: true)
@JsonSerializable(createFieldMap: true, createPerFieldToJson: true)
@Collection<Model>(...)
class MyModel {...}
```
Expand Down