An encoder that supports encoding key-value pairs.
An SelfEncodable or Encodable implementation can encode each key-value pair by repeatedly calling a encoding method. All data formats should support encoding different types of values in the same collection.
Formats may choose to use either the key or id parameter for encoding, as some formats use
String keys like JSON and others use int ids like Protobuf. The Encodable implementation should
provide values for both. If no id is provided, formats like Protobuf may not work.
The end method should be called when all key-value pairs have been encoded.
- Implementers
- Available extensions
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
-
canEncodeCustom<
T> () → bool -
Checks if the encoder can encode the custom type
T. -
encodeBool(
String key, bool value, {int? id}) → void - Encodes a boolean value for the given key or id.
-
encodeBoolOrNull(
String key, bool? value, {int? id}) → void - Encodes a nullable boolean value for the given key or id.
-
encodeDouble(
String key, double value, {int? id}) → void - Encodes a double value for the given key or id.
-
encodeDoubleOrNull(
String key, double? value, {int? id}) → void - Encodes a nullable double value for the given key or id.
-
encodeFuture<
T> (String key, Future< T> value, {Encodable<T> ? using}) → void -
Available on KeyedEncoder, provided by the AsyncKeyedEncoder extension
Encodes a Future ofTusing the provided Encodable. -
encodeFutureOrNull<
T> (String key, Future< T> ? value, {Encodable<T> ? using}) → void -
Available on KeyedEncoder, provided by the AsyncKeyedEncoder extension
Encodes a Future ofTor null using the provided Encodable. -
encodeInt(
String key, int value, {int? id}) → void - Encodes an integer value for the given key or id.
-
encodeIntOrNull(
String key, int? value, {int? id}) → void - Encodes a nullable integer value for the given key or id.
-
encodeIterable<
E> (String key, Iterable< E> value, {int? id, Encodable<E> ? using}) → void -
Encodes an iterable of
Efor the given key or id. -
encodeIterableOrNull<
E> (String key, Iterable< E> ? value, {int? id, Encodable<E> ? using}) → void -
Encodes a nullable iterable of
Efor the given key or id. -
encodeIterated(
String key, {int? id}) → IteratedEncoder - Starts encoding an iterated collection or nested values for the given key or id.
-
encodeKeyed(
String key, {int? id}) → KeyedEncoder - Starts encoding a keyed collection or key-value pairs for the given key or id.
-
encodeMap<
K, V> (String key, Map< K, V> value, {int? id, Encodable<K> ? keyUsing, Encodable<V> ? valueUsing}) → void -
Encodes a map of
KandVfor the given key or id. -
encodeMapOrNull<
K, V> (String key, Map< K, V> ? value, {int? id, Encodable<K> ? keyUsing, Encodable<V> ? valueUsing}) → void -
Encodes a nullable map of
KandVfor the given key or id. -
encodeNull(
String key, {int? id}) → void - Encodes 'null' for the given key or id.
-
encodeNum(
String key, num value, {int? id}) → void - Encodes a num value for the given key or id.
-
encodeNumOrNull(
String key, num? value, {int? id}) → void - Encodes a nullable num value for the given key or id.
-
encodeObject<
T> (String key, T value, {int? id, Encodable< T> ? using}) → void -
Encodes an object of type
Tfor the given key or id. -
encodeObjectOrNull<
T> (String key, T? value, {int? id, Encodable< T> ? using}) → void -
Encodes a nullable object of type
Tfor the given key or id. -
encodeReference<
T> (String key, T value, {Encodable< T> ? using}) → void -
Available on KeyedEncoder, provided by the ReferenceKeyedEncoder extension
Encodes a Reference ofTusing the provided Encodable. -
encodeReferenceOrNull<
T> (String key, T? value, {Encodable< T> ? using}) → void -
Available on KeyedEncoder, provided by the ReferenceKeyedEncoder extension
Encodes a Reference ofTor null using the provided Encodable. -
encodeStream<
T> (String key, Stream< T> value, {Encodable<T> ? using}) → void -
Available on KeyedEncoder, provided by the AsyncKeyedEncoder extension
Encodes a Stream ofTusing the provided Encodable. -
encodeStreamOrNull<
T> (String key, Stream< T> ? value, {Encodable<T> ? using}) → void -
Available on KeyedEncoder, provided by the AsyncKeyedEncoder extension
Encodes a Stream ofTor null using the provided Encodable. -
encodeString(
String key, String value, {int? id}) → void - Encodes a string value for the given key or id.
-
encodeStringOrNull(
String key, String? value, {int? id}) → void - Encodes a nullable string value for the given key or id.
-
end(
) → void - Ends encoding the keyed collection.
-
isHumanReadable(
) → bool - Whether a Encodable implementation should prefer to encode their human-readable form.
-
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