whatsNext method
Returns the actual or preferred DecodingType of the encoded data.
Self-describing formats may return a DecodingType that indicates the type of the encoded data, or the preferred way of decoding it.
Non-self-describing formats may only return DecodingType.unknown for all types. In this case, the Decodable implementation must try the appropriate decoding method based on the expected type.
Implementation
@override
DecodingType whatsNext() {
final b = _unpacker.whatIsNext();
return switch (b) {
0xc0 => DecodingType.nil,
<= 0x7f || >= 0xe0 || (>= 0xcc && <= 0xd3) => DecodingType.int,
0xc2 || 0xc3 => DecodingType.bool,
0xca || 0xcb => DecodingType.double,
0xc0 || 0xd9 || 0xda || 0xdb => DecodingType.string,
_ when (b & 0xE0) == 0xA0 => DecodingType.string,
0xc4 || 0xc5 || 0xc6 => DecodingType<Uint8List>.custom(),
(>= 0x90 && <= 0x9F) || 0xdc || 0xdd => DecodingType.iterated,
(>= 0x80 && <= 0x8F) || 0xde || 0xdf => DecodingType.keyed,
(>= 0xd4 && <= 0xd8) || (>= 0xc7 && <= 0xc9) => switch (_unpacker._getExtType()) {
-1 => DecodingType<DateTime>.custom(),
_ => DecodingType.unknown,
},
_ => DecodingType.unknown,
};
}