JsonKey class
An annotation used to specify how a field is serialized.
This annotation can be used on both class properties and constructor parameters.
- Annotations
-
- @Target.new({TargetKind.field, TargetKind.getter, TargetKind.parameter})
Constructors
- JsonKey({@Deprecated('Has no effect') bool? nullable, Object? defaultValue, bool? disallowNullValue, Function? fromJson, @Deprecated('Use `includeFromJson` and `includeToJson` with a value of `false` ' 'instead.') bool? ignore, bool? includeFromJson, bool? includeIfNull, bool? includeToJson, String? name, Object? readValue(Map, String)?, bool? required, Function? toJson, Enum? 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 its value isnull.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.
no setterinherited
- ignore β bool?
-
trueif the generator should ignore this field completely.final - includeFromJson β bool?
-
Determines whether a field should be included (or excluded) when decoding
an object from JSON.
final
- includeIfNull β bool?
-
Specifies whether fields with
nullvalues should be included in the serialized output.final - includeToJson β bool?
-
Determines whether a field should be included (or excluded) when encoding
an object to JSON.
final
- name β String?
-
The key to use in the JSON map when reading and writing values for the
annotated field.
final
- readValue β Object? Function(Map, String)?
-
Customizes how a value is read from the source JSON map.
final
- required β bool?
-
If
true, generated code forfromJsonwill verify that the source JSON map contains the associated key.final - runtimeType β Type
-
A representation of the runtime type of the object.
no setterinherited
- toJson β Function?
-
A Function to use when encoding the annotated field to JSON.
final
- unknownEnumValue β Enum?
-
The value to use for an enum field when the provided value does not match
any of the values in the source enum.
final
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
Constants
- nullForUndefinedEnumValue β const Enum
- Sentinel value for use with unknownEnumValue.