JsonKey class Null safety

An annotation used to specify how a field is serialized.

Annotations
  • @Target({TargetKind.field, TargetKind.getter})

Constructors

JsonKey({@Deprecated('Has no effect') bool? nullable, Object? defaultValue, bool? disallowNullValue, Function? fromJson, bool? ignore, bool? includeIfNull, String? name, bool? required, Function? toJson, Object? unknownEnumValue})
Creates a new JsonKey instance. [...]
const

Properties

defaultValue Object?
The value to use if the source JSON does not contain this key or if the value is null.
final
disallowNullValue bool?
If true, generated code will throw a DisallowedNullValueException if the corresponding key exists, but the value is null. [...]
final
fromJson Function?
A Function to use when decoding the associated JSON value to the annotated field. [...]
final
hashCode int
The hash code for this object. [...]
read-only, inherited
ignore bool?
true if the generator should ignore this field completely. [...]
final
includeIfNull bool?
Whether the generator should include fields with null values in the serialized output. [...]
final
name String?
The key in a JSON map to use when reading and writing values corresponding to the annotated fields. [...]
final
required bool?
When true, generated code for fromJson will verify that the source JSON map contains the associated key. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
toJson Function?
A Function to use when encoding the annotated field to JSON. [...]
final
unknownEnumValue Object?
The value to use for an enum field when the value provided is not in the source enum. [...]
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Constants

nullForUndefinedEnumValue → const Object
Sentinel value for use with unknownEnumValue. [...]
r'JsonKey.nullForUndefinedEnumValue'