encodeWithType method
Encode the provided object to a json-formatted String, include class
name so that it can be decoded even if the 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,
);
}