JsonKey<T> class

Adding the JsonKey annotation to a field makes it customizable when generating fromJson/toJson methods

Available features

name Replaces the field's access name on json

fromJson Custom converter from json value to object

toJson Custom converter from json value to object

ignore Ignores adding the field in the from/to json methods

nameConvention Transforms the variable name into one of the nameJsonKeyNameConventionConvention typing cases

Annotations
  • @Target.new(<TargetKind>{TargetKind.field, TargetKind.parameter, TargetKind.getter})

Constructors

JsonKey({String? name, FromJsonConverter<T>? fromJson, ToJsonConverter<T>? toJson, bool? ignore, JsonKeyNameConvention? nameConvention})
const

Properties

fromJson → FromJsonConverter<T>?
Custom converter from json value to object
final
hashCode → int
The hash code for this object.
no setterinherited
ignore → bool?
Ignores adding the field in the from/to json methods
final
name → String?
Replaces the field's access name on json
final
nameConvention → JsonKeyNameConvention?
Transforms the variable name into one of the nameJsonKeyNameConventionConvention typing cases
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
toJson → ToJsonConverter<T>?
Custom converter from json value to object
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