SnapshotDecoder class

Holds methods to convert Snapshots to objects of specific types.

The SnapshotDecoder.defaultDecoder handles conversions of common dart types. The following conversions are available by default:

from type to type format description
String DateTime null uses DateTime.parse
num DateTime 'epoch' milliseconds since epoch
String Uri null uses Uri.parse
String int 'radix:{radix}' uses int.parse with radix
String int 'string' uses int.parse
String double 'string' uses double.parse
String num 'string' uses num.parse
String DateTime '{date-format}' uses intl.DateFormat.parse

A custom decoder can be created by calling one of the constructors and registering new conversion functions. Before a decoder can be used, it needs to be sealed by calling SnapshotDecoder.seal. Once sealed, it is not allowed to register any additional converters.


Create a new, unsealed SnapshotDecoder containing the default converters
Create a new, unsealed empty SnapshotDecoder
SnapshotDecoder.from(SnapshotDecoder other)
Create a new, unsealed SnapshotDecoder containing the converters in the decoder other.


hashCode int
The hash code for this object.
no setterinherited
isSealed bool
true when this decoder is sealed
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


convert<T>(Snapshot input, {String? format}) → T
Converts input to an object of type T
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
register<S, T>(T converter(S), {Pattern? format}) → void
Registers a conversion function
seal() → void
Seals this decoder
toString() String
A string representation of this object.


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

Static Properties

defaultDecoder SnapshotDecoder
The default, sealed SnapshotDecoder
no setter