fromTypedMap<T> static method
JsonObject
fromTypedMap<T>({
- required Map<
T, dynamic> data, - required String keyToString(
- T
- required T toTypedKey(),
- String key = "",
override
Construct a new JsonObject where each key is an enumerated value.
Implementation
static JsonObject fromTypedMap<T>(
{required Map<T, dynamic> data,
/// Convert enumerated key to String key.
required String Function(T) keyToString,
/// Convert String key to enumerated value.
required T Function(String) toTypedKey,
/// Node key.
String key = ""}) =>
JsonTypeObject(
toTypedKey: toTypedKey,
keyToString: keyToString,
key: key,
data: data
.map((key, value) => MapEntry(keyToString.call(key), value))
.map(_buildJsonNodeMap));