PrefCodec class

Encodes and decodes tagged preference values.

Layout is [tag u8][payload…]:

  • string — UTF-8 bytes
  • int64 — 8 bytes, little-endian two's complement
  • float64 — 8 bytes, little-endian IEEE-754
  • boolean — 1 byte, 0 or 1
  • stringList — [count u32][len u32][utf8]…, all little-endian
  • bytes — verbatim

Fixed-width integers keep decoding allocation-free, and every length is bounds-checked against the buffer before it is used to slice.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

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

Static Methods

decodeBool(String key, Uint8List raw) → bool
Decodes a boolean payload.
decodeBytes(String key, Uint8List raw) → Uint8List
Decodes an opaque byte payload.
decodeDouble(String key, Uint8List raw) → double
Decodes a double payload.
decodeDynamic(String key, Uint8List raw) → Object
Decodes any tagged value into its natural Dart type.
decodeInt(String key, Uint8List raw) → int
Decodes an integer payload.
decodeString(String key, Uint8List raw) → String
Decodes a string payload.
decodeStringList(String key, Uint8List raw) → List<String>
Decodes a string-list payload, bounds-checking every element.
encodeBool(bool v) → Uint8List
Encodes a boolean.
encodeBytes(Uint8List v) → Uint8List
Encodes opaque bytes.
encodeDouble(double v) → Uint8List
Encodes a double.
encodeInt(int v) → Uint8List
Encodes a 64-bit signed integer.
encodeString(String v) → Uint8List
Encodes a UTF-8 string.
encodeStringList(List<String> v) → Uint8List
Encodes a list of strings.
expect(String key, Uint8List raw, PrefType want) → void
Verifies the tag matches want, throwing PhoenixTypeMismatch if not.
typeOf(String key, Uint8List raw) → PrefType
Reads the type tag, or throws when the buffer is empty or unknown.