Codec<T> class final

Converts a typed Dart value to database storage and decodes it on reads.

A codec defines a storage family and symmetric conversion functions. Use nullable for SQL NULL and map for domain-specific Dart types.

Constructors

Codec(String sqlType, T _decode(Object? value), Object? _encode(T value))
Creates an explicit storage codec; conversion errors propagate to callers.
const
Codec.integer(T _decode(Object? value), int encode(T value))
Stores a domain value as a SQL integer.
const
Codec.text(T _decode(Object? value), String encode(T value))
Stores a domain value as SQL text.
const

Properties

acceptsNull → bool
Whether T permits a null Dart result.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sqlType → String
Logical storage family used when rendering and binding SQL.
final

Methods

decode(Object? value) → T
Converts a raw stored value into T.
encode(T value) → Object?
Converts value into a value supported by the SQL driver.
map<R>(R from(T), T to(R)) → Codec<R>
Adds domain conversions while preserving this codec's storage family.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nullable() → Codec<T?>
Handles SQL NULL before delegating non-null values to this codec.
sameStorageAs(Codec<Object?> other) → bool
Whether two codecs have the same storage and decoding identity. Nullable wrappers preserve identity; independently mapped codecs do not.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited