Unverified Commit 6b500fa7 authored by Kinarobin's avatar Kinarobin Committed by GitHub

dispose image when cache clear (#76600)

parent c8c681f6
...@@ -188,6 +188,9 @@ class ImageCache { ...@@ -188,6 +188,9 @@ class ImageCache {
}, },
); );
} }
for (final _CachedImage image in _cache.values) {
image.dispose();
}
_cache.clear(); _cache.clear();
_pendingImages.clear(); _pendingImages.clear();
_currentSizeBytes = 0; _currentSizeBytes = 0;
......
...@@ -34,7 +34,7 @@ void main() { ...@@ -34,7 +34,7 @@ void main() {
await tester.pumpWidget(TestWidget(key)); await tester.pumpWidget(TestWidget(key));
final DisposableBuildContext context = DisposableBuildContext(key.currentState!); final DisposableBuildContext context = DisposableBuildContext(key.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
...@@ -69,7 +69,7 @@ void main() { ...@@ -69,7 +69,7 @@ void main() {
)); ));
final DisposableBuildContext context = DisposableBuildContext(key.currentState!); final DisposableBuildContext context = DisposableBuildContext(key.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
...@@ -109,7 +109,7 @@ void main() { ...@@ -109,7 +109,7 @@ void main() {
)); ));
final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!); final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
...@@ -166,7 +166,7 @@ void main() { ...@@ -166,7 +166,7 @@ void main() {
)); ));
final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!); final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
...@@ -233,7 +233,7 @@ void main() { ...@@ -233,7 +233,7 @@ void main() {
)); ));
final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!); final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
...@@ -298,7 +298,7 @@ void main() { ...@@ -298,7 +298,7 @@ void main() {
)); ));
final DisposableBuildContext context = DisposableBuildContext(key.currentState!); final DisposableBuildContext context = DisposableBuildContext(key.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
...@@ -349,7 +349,7 @@ void main() { ...@@ -349,7 +349,7 @@ void main() {
)); ));
final DisposableBuildContext context = DisposableBuildContext(key.currentState!); final DisposableBuildContext context = DisposableBuildContext(key.currentState!);
final TestImageProvider testImageProvider = TestImageProvider(testImage); final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>( final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
context: context, context: context,
imageProvider: testImageProvider, imageProvider: testImageProvider,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment