factory ShelfUnmodifiableMap()

in lib/src/shelf_unmodifiable_map.dart [23:45]


  factory ShelfUnmodifiableMap(
    Map<String, Object>? source, {
    bool ignoreKeyCase = false,
  }) {
    if (source is ShelfUnmodifiableMap &&
        //        !ignoreKeyCase: no transformation of the input is required
        // source._ignoreKeyCase: the input cannot be transformed any more
        (!ignoreKeyCase || source._ignoreKeyCase)) {
      return source;
    }

    if (source == null || source.isEmpty) {
      return const _EmptyShelfUnmodifiableMap();
    }

    if (ignoreKeyCase) {
      source = CaseInsensitiveMap<Object>.from(source);
    } else {
      source = Map<String, Object>.from(source);
    }

    return ShelfUnmodifiableMap._(source, ignoreKeyCase);
  }