toJson method
Returns a serializable Json value.
if shallow
, it will not serialize inner Json values
Implementation
Object? toJson({bool shallow = false}) {
if (shallow) {
return value;
} else {
return when(
map: (map) => map.map(
(key, value) => MapEntry(key, value.toJson()),
),
list: (list) => list.map((e) => e.toJson()).toList(),
number: (n) => n,
str: (str) => str,
boolean: (b) => b,
none: (_) => null,
);
}
}