maximumSize property

int maximumSize

Maximum number of entries to store in the cache.

Once this many entries have been cached, the least-recently-used entry is evicted when adding a new entry.

Implementation

int get maximumSize => _maximumSize;
void maximumSize=(int value)

Changes the maximum cache size.

If the new size is smaller than the current number of elements, the extraneous elements are evicted immediately. Setting this to zero and then returning it to its original value will therefore immediately clear the cache.

Implementation

set maximumSize(int value) {
  assert(value >= 0);
  if (value == maximumSize) {
    return;
  }
  TimelineTask? debugTimelineTask;
  if (!kReleaseMode) {
    debugTimelineTask = TimelineTask()..start(
      'ImageCache.setMaximumSize',
      arguments: <String, dynamic>{'value': value},
    );
  }
  _maximumSize = value;
  if (maximumSize == 0) {
    clear();
  } else {
    _checkCacheSize(debugTimelineTask);
  }
  if (!kReleaseMode) {
    debugTimelineTask!.finish();
  }
}