Codable<T, Self extends Codable<T, Self>> class abstract

The base contract for all data models or objects that require mapping from a remote representation to a local Dart object (decoding/deserialization).

This abstract class enforces type safety for mapping operations and integrates with EquatableMixin for reliable object comparison.

Type Parameters:

  • T: The remote data type (e.g., Map<String, dynamic>, String, or Uint8List).
  • Self: The concrete type of the implementing class, ensuring the decode method returns an instance of the class that implements Codable. This is known as the F-Bounded Polymorphism pattern.
Annotations
  • @immutable

Constructors

Codable()
The base contract for all data models or objects that require mapping from a remote representation to a local Dart object (decoding/deserialization).
const

Properties

encoding Encoding?
The specific string encoding (e.g., 'utf-8') required for the remote data.
no setter
hashCode int
The hash code for this object.
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializer Codec?
The JSON codec (serializer) used to transform between raw JSON strings/bytes and Dart objects.
no setter
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setter

Methods

decode(T remote) → Self
Decodes the remote data representation into an instance of the local Dart model.
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