encode method Null safety
Encode gson
gson.encode({"hello": "world"}) // >> {hello: "world"}
for beautier gson
gson.encode({"hello": "world"},beautify: true);
// >> {
// >> hello: "world"
// >> }
You can also set the indent (the amount of spaces the gson is indented with)
Implementation
String encode(dynamic obj,
{bool beautify = false,
int indent = 2,
jsonBooleans = false,
quoteMapKeys = false}) {
return encoder.encode(obj,
beautify: beautify,
indent: indent,
jsonBooleans: jsonBooleans,
quoteMapKeys: quoteMapKeys);
}