I'm not sure this is correct. null is a not a valid key in Dart Maps, so if there was no previous association for `value`, oldKey` will be null and the remove() could throw. Maybe only do this if `replace` is true?