updateKeys method

Map<String, V> updateKeys(
  1. String newKey(
    1. String key
    )
)

Returns a new map with new keys default blank map if null. Example: final map= {'framework': "Flutter", 'Language': "Dart"}; final newMap= map.updateKeys((key) => key+"'s"); print(newMap); output: {framework's: Flutter, Language's: Dart}

Implementation

Map<String, V> updateKeys(String Function(String key) newKey) {
  if (isNullOrEmpty) return {};
  final map = <String, V>{};
  for (var key in this!.keys) {
    map.addAll({newKey.call(key): this?[key] as V});
    // map[key] = this?[key] as V;
  }
  return map;
}