Skip to content

Commit

Permalink
feat: Add clearSnapshot function (#2897)
Browse files Browse the repository at this point in the history
The Snapshot mixin was missing a function to clear the snapshot. This is
useful for when you want to invalidate the picture, but don't want to
immediately pre-render the image yet.
  • Loading branch information
pdeveltere committed Dec 4, 2023
1 parent a31486f commit d4decd2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/flame/lib/src/components/mixins/snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ mixin Snapshot on PositionComponent {
return _picture!;
}

/// clear the current snapshot. will trigger the creation of a new snapshot
/// next time renderTree is called.
void clearSnapshot() {
_picture = null;
}

@override
void renderTree(Canvas canvas) {
if (renderSnapshot) {
Expand Down

0 comments on commit d4decd2

Please sign in to comment.