fromTypedMap<T> static method

JsonObject fromTypedMap<T>({
  1. required Map<T, dynamic> data,
  2. required String keyToString(
    1. T
    ),
  3. String key = "",
})

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,

        /// Node key.
        String key = ""}) =>
    JsonObject(
        key: key,
        data: data
            .map((key, value) => MapEntry(keyToString.call(key), value))
            .map(_buildJsonNodeMap));