fromTypedMap<T> static method

JsonObject fromTypedMap<T>({
  1. required Map<T, dynamic> data,
  2. required String keyToString(
    1. T
    ),
  3. required T toTypedKey(
    1. String
    ),
  4. 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));