ModelBuilder class abstract
Extend this class to build a json model Can have JsonType instances as fields or "entries"
Example:
class Person extends ModelBuilder {
@override
Iterable<JsonType> get values => [name, age];
JsonString get name => jsonString('name');
JsonInt get age => jsonInt('age');
}
final someone = Person()
..setFromJson({'name: 'Tomás'})
..age.set(20);
person.toJson();
- Implemented types
- Implementers
Constructors
- ModelBuilder([dynamic source])
Properties
-
entries
→ Iterable<
MapEntry< String, JsonType> > -
Get all entries
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
keys
→ Iterable<
String> -
Get all model keys
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Iterable<
JsonType> -
All entries values defined by model
no setter
Methods
-
jsonBool(
String name, [dynamic defaultJsonValue]) → JsonBool -
Creates a entry of type
JsonBool
with a given name -
jsonBoolNullable(
String name, [dynamic defaultJsonValue]) → JsonBoolNullable -
Creates a entry of type
JsonBoolNullable
with a given name -
jsonDateTime(
String name, [dynamic defaultJsonValue]) → JsonDateTime -
Creates a entry of type
JsonDateTime
with a given name -
jsonDateTimeNullable(
String name, [dynamic defaultJsonValue]) → JsonDateTimeNullable -
Creates a entry of type
JsonDateTimeNullable
with a given name -
jsonDouble(
String name, [dynamic defaultJsonValue]) → JsonDouble -
Creates a entry of type
JsonDouble
with a given name -
jsonDoubleNullable(
String name, [dynamic defaultJsonValue]) → JsonDoubleNullable -
Creates a entry of type
JsonDoubleNullable
with a given name -
jsonEntry<
T extends JsonType> (String name, T creator(), [dynamic defaultJsonValue]) → T - Add entry to json model. Entries are defined as getters
-
jsonInt(
String name, [dynamic defaultJsonValue]) → JsonInt -
Creates a entry of type
JsonInt
with a given name -
jsonIntNullable(
String name, [int? defaultJsonValue]) → JsonIntNullable -
Creates a entry of type
JsonIntNullable
with a given name -
jsonList<
T extends JsonType> (String name, T childCreator(), [dynamic defaultJsonValue]) → JsonList< T> -
Creates a entry of type
JsonList
with a given name -
jsonListNullable<
T extends JsonType> (String name, T childCreator(), [dynamic defaultJsonValue]) → JsonListNullable< JsonType> -
Creates a entry of type
JsonListNullable
with a given name -
jsonMap<
T extends JsonType> (String name, T childCreator(), [int? defaultJsonValue]) → JsonMap< T> -
Creates a entry of type
JsonMap
with a given name -
jsonMapNullable<
T extends JsonType> (String name, T childCreator(), [dynamic defaultJsonValue]) → JsonMapNullable< JsonType> -
Creates a entry of type
JsonMapNullable
with a given name -
jsonModel<
T extends ModelBuilder> (String name, T creator(), [dynamic defaultJsonValue]) → T -
jsonNullable<
T extends JsonType> (String name, T childCreator(), [dynamic defaultJsonValue]) → JsonNullable< T> -
Creates a entry of type
JsonNullable
with a given name -
jsonString(
String name, [String? defaultJsonValue]) → JsonString -
Creates a entry of type
JsonString
with a given name -
jsonStringNullable(
String name, [String? defaultJsonValue]) → JsonStringNullable -
Creates a entry of type
JsonStringNullable
with a given name -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setFromJson(
dynamic json) → bool -
Fill model with data provided by json
Example:
override
-
toJson(
) → dynamic -
Convert object to json compatible types
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited