Serialize class
Makes dox_builder write fast JSON code for a class.
Put it on a Serializer subclass. Its convert() then gets a JSON
writer that writes the map of convert() with no Map in between.
Put it on a plain class. Its public final fields are then written as
JSON, with snake_case keys (@Name changes one key), like a @Dto.
Add part '<file>.g.dart'; to the file and run
dart run build_runner build. lib/generated/container.g.dart then
gives the writers to Dox.
@Serialize()
class UserSerializer extends Serializer<User> {
UserSerializer(super.data);
@override
Map<String, dynamic> convert(User m) {
return <String, dynamic>{'id': m.id, 'name': m.name};
}
}
Constructors
- Serialize()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited