renameKey method
Returns a new map with the key from renamed to to.
{'old': 1}.renameKey('old', 'new') // {'new': 1}
Implementation
Map<K, V> renameKey(K from, K to) {
if (!containsKey(from)) return Map.from(this);
final result = Map<K, V>.from(this);
result[to] = result.remove(from) as V;
return result;
}