Skip to content

Commit

Permalink
Fix field images not disposing properly (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 authored Oct 6, 2024
1 parent 3e1dc36 commit 50659db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/services/field_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Field {
void loadFieldImage() {
fieldImage = Image.asset(jsonData['field-image']);
fieldImage.image
.resolve(const ImageConfiguration())
.resolve(ImageConfiguration.empty)
.addListener(ImageStreamListener((image, synchronousCall) {
fieldImageWidth = image.image.width;
fieldImageHeight = image.image.height;
Expand All @@ -115,11 +115,11 @@ class Field {
}));
}

void dispose() {
void dispose() async {
instanceCounter--;
if (instanceCounter <= 0) {
fieldImage.image.evict();
PaintingBinding.instance.imageCache.clear();
await fieldImage.image.evict();
imageCache.clear();
fieldImageLoaded = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class ListLayoutModel extends LayoutContainerModel {
container.unSubscribe();
container.disposeModel(
deleting: true);
container.forceDispose();

notifyListeners();
});
Expand Down
1 change: 0 additions & 1 deletion lib/widgets/nt_widgets/nt_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ class NTWidgetModel extends ChangeNotifier {
}

void forceDispose() {
disposeWidget(deleting: true);
_forceDispose = true;
dispose();
}
Expand Down

0 comments on commit 50659db

Please sign in to comment.