encode<T> static method
void
encode<T>(])
Encodes an optional value to a JSON map if not null.
toJson - Optional function to encode objects. If not provided, value is used directly.
Implementation
static void encode<T>(
Map<String, dynamic> json,
String key,
T? value, [
Map<String, dynamic> Function(T)? toJson,
]) {
if (value != null) {
json[key] = toJson != null ? toJson(value) : value;
}
}