angel3_serialize_generator 10.0.0
angel3_serialize_generator: ^10.0.0 copied to clipboard
Angel3 model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling.
Angel3 Serialize Generator #
The builder for generating JSON serialization code for Angel3 framework.
Installation #
In your pubspec.yaml:
dependencies:
angel3_serialize: ^10.0.0
dev_dependencies:
angel3_serialize_generator: ^10.0.0
build_runner: ^2.4.0
Usage #
-
Create a model class in
todo.dartand annotate it with@serializableand appendEntitysuffix to the class name.import 'package:angel3_serialize/angel3_serialize.dart'; part 'todo.g.dart'; @serializable class TodoEntity { String? text; bool? completed; } -
Run the following command to generate the associated
todo.g.dartfile for serialization.dart run build_runner buildThe generated class is named without the
Entitysuffix (or a_prefix):Todo, withTodoSerializer,TodoFieldsand atodoSerializercodec. A class whose name only ends with the letters of the suffix, such asUserIdentity, keeps its name.
Migrating from 9.x to 10.0.0 #
The breaking changes of each release are listed in the CHANGELOG. Those of 10.0.0 that may need changes in an app:
- Regenerate your models with
dart run build_runner build --delete-conflicting-outputs: generatedhashCodegetters useObject.hashAllinstead ofhashObjects. - Class names: a generated class is named by removing a prefix (
_,Entity), then a suffix (Entity), matched by case, soUserIdentitykeeps its name, where it becameUserId. includeAnnotations: a value that is not a constant instance of a class or enum fails the build.- Code that uses the generator's API:
SerializableFieldMirror.serializeranddeserializerare the names of functions, asStrings, where they wereSymbols.