putMapIfNotEmpty method
Maps name to map after wrapping it in a Map, clobbering any existing name/value
mapping with the same name. If the map is empty, any existing mapping for name is removed.
If the objects in map are JSONable, then they are converted to Map first.
Implementation
void putMapIfNotEmpty(String name, Map<String, dynamic> map) {
Map<String, dynamic> map2 =
map.map((key, value) => MapEntry(key, _wrapJSON(value)));
if (map2.isEmpty) {
this?.remove(name);
return;
}
put(name, map2);
}