From e0a260cfb2b539f6ba7525a2cc2bc7c937bb6cac Mon Sep 17 00:00:00 2001 From: Geoffrey Marizy Date: Wed, 18 Oct 2023 12:57:32 +0200 Subject: [PATCH] docs(cloud_firestore_odm_generator): ODM generator now require create_per_field_to_json: true --- packages/cloud_firestore_odm/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/cloud_firestore_odm/README.md b/packages/cloud_firestore_odm/README.md index 005a13554e5d..d406cd36947f 100644 --- a/packages/cloud_firestore_odm/README.md +++ b/packages/cloud_firestore_odm/README.md @@ -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: @@ -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(...) class MyModel {...} ```