maximumSizeBytes property

int get maximumSizeBytes

Maximum size of entries to store in the cache in bytes.

Once more than this amount of bytes have been cached, the least-recently-used entry is evicted until there are fewer than the maximum bytes.

Implementation

int get maximumSizeBytes => _maximumSizeBytes;
set maximumSizeBytes (int value)

Changes the maximum cache bytes.

If the new size is smaller than the current size in bytes, 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 maximumSizeBytes(int value) {
  assert(value >= 0);
  if (value == _maximumSizeBytes) {
    return;
  }
  TimelineTask? debugTimelineTask;
  if (!kReleaseMode) {
    debugTimelineTask = TimelineTask()..start(
      'ImageCache.setMaximumSizeBytes',
      arguments: <String, dynamic>{'value': value},
    );
  }
  _maximumSizeBytes = value;
  if (_maximumSizeBytes == 0) {
    clear();
  } else {
    _checkCacheSize(debugTimelineTask);
  }
  if (!kReleaseMode) {
    debugTimelineTask!.finish();
  }
}