Where is the definition of `map.clear()`?
My answer is based on the assumption that you want the implementation used when Dart is running natively and not on the web.
The default Map
in Dart is a LinkedHashMap
. There are several layers before getting the implementation of clear()
but I expect this is the one you are looking for:
void clear() {
if (!isEmpty) {
_index = _uninitializedIndex;
_hashMask = _HashBase._UNINITIALIZED_HASH_MASK;
_data = _uninitializedData;
_usedData = 0;
_deletedKeys = 0;
}
}
https://github.com/dart-lang/sdk/blob/2.15.1/sdk/lib/_internal/vm/lib/compact_hash.dart#L333-L341