decode method
- String? value, {
- Encoding? charset,
- DecodeKind kind = DecodeKind.value,
Unified scalar decode with key/value context.
Uses a provided custom Decoder when set; otherwise falls back to Utils.decode
.
For backward compatibility, a LegacyDecoder can be supplied and is honored
when no primary Decoder is provided. The kind
will be DecodeKind.key for
keys (and key segments) and DecodeKind.value for values. The default implementation
does not vary decoding based on kind
. If your decoder returns null
, that null
is preserved — no fallback decoding is applied.
Implementation
dynamic decode(
String? value, {
Encoding? charset,
DecodeKind kind = DecodeKind.value,
}) {
if (_decoder != null) {
return _decoder!(value, charset: charset, kind: kind);
}
if (_legacyDecoder != null) {
return _legacyDecoder!(value, charset: charset);
}
return Utils.decode(value, charset: charset ?? this.charset);
}