decodeObject<T> method
Decodes the data as an object of type T
.
This forwards the decoding to the provided Decodable implementation.
Otherwise tries to decode the data to a supported primitive type T
.
This should only be called if the format returned a DecodingType<T>
from whatsNext or
is otherwise known to support T
as a custom type.
Implementation
@override
T decodeObject<T>({Decodable<T>? using}) {
if (<T>[] is List<Stream> && (using is AsyncDecodable || using == null)) {
final marker = _readMarker();
if (marker == null) {
expect('Stream');
}
return _createStream(marker, using is AsyncDecodable ? using as AsyncDecodable : null) as T;
}
if (<T>[] is List<Future> && (using is AsyncDecodable || using == null)) {
final marker = _readMarker();
if (marker == null) {
expect('Future');
}
return _createStream(marker, using is AsyncDecodable ? using as AsyncDecodable : null).first as T;
}
if (<T>[] is List<Reference> && (using is ReferenceDecodable || using == null)) {
final marker = _readMarker();
if (marker == null) {
expect('Reference');
}
return _createReference(marker, using is ReferenceDecodable ? using as ReferenceDecodable : null) as T;
}
if (using == null) {
final marker = _readMarker();
if (marker != null) {
return (_isSync ? _createReference(marker, null) : _createStream(marker, null)) as T;
}
}
return super.decodeObject<T>(using: using);
}