encode method
Encode the object into the SON format.
If withDictionary
is true
, the encoder will write the strings into a
dictionary defined within the binary data. Otherwise it will write them
in-place.
If withDictionary
is not given, it defaults to the withDictionary
that was used to instantiate this
.
Implementation
@override
Uint8List encode(Object? input, {bool? withDictionary}) {
// Switch between const objects to avoid allocation.
final encoder = switch (withDictionary ?? _withDictionary) {
true => const SonEncoder(withDictionary: true),
false => const SonEncoder(withDictionary: false),
};
return encoder.convert(input);
}