encodeWithType method
Encode the provided object
to a json-formatted String, include class
name so that it can be decoded even if th class is unknown.
If formatted
is true, the output will be formatted with two spaces
indentation.
Implementation
String encodeWithType(
Object? object, {
bool formatted = false,
}) {
return encode(
wrapWithClassName(object),
formatted: formatted,
);
}