toIdenticalKeyedMap function

Map<ThemeRef, Object> toIdenticalKeyedMap(
  1. Map<ThemeRef, Object>? theme
)

Implementation

Map<ThemeRef, Object> toIdenticalKeyedMap(Map<ThemeRef, Object>? theme) {
  if (theme == null)
    return const {};
  else {
    // Note: We add the maps like this, because the original theme may have ThemeRef values
    // which present our weird equality, so it may fail if we do it any other way.
    var result = Map<ThemeRef, Object>.identity();
    List<ThemeRef> keys = theme.keys.toList();
    List<Object> values = theme.values.toList();
    for (int i = 0; i < keys.length; i++) {
      result[keys[i]] = values[i];
    }
    return result;
  }
}