feat: add initialPhase and onPhaseUpdate parameters#35
Open
FinSchuiling wants to merge 2 commits intoben-fornefeld:mainfrom
Open
feat: add initialPhase and onPhaseUpdate parameters#35FinSchuiling wants to merge 2 commits intoben-fornefeld:mainfrom
FinSchuiling wants to merge 2 commits intoben-fornefeld:mainfrom
Conversation
…start Two bugs fixed: 1. The anonymous closure added to controller.isAnimating was never removed in dispose(), causing stale callbacks (and potential setState-after-dispose crashes) when the widget is removed while the controller outlives it. Fix: store the listener reference in _controllerListener and remove it in dispose(). 2. After calling _ticker.stop(), calling _ticker.start() again hits Flutter's "Ticker already started" assertion because a stopped Ticker cannot be restarted. Fix: when the controller requests animation to resume after a stop, create a fresh Ticker via _initTicker() instead of calling start() on the existing one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- `initialPhase` (optional double): when non-null, the animation starts from this phase value instead of 0. Useful for resuming from a previously saved state. Ignored if `seed` is set. - `onPhaseUpdate` (optional callback): called each tick with the current animation phase. Allows consumers to persist the phase so they can later restore it via `initialPhase` or display a static gradient at the paused position using `seed`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two optional parameters to
AnimatedMeshGradient:initialPhase(double?): When non-null, the animation starts from this phase value instead of 0. Useful for resuming from a previously saved state (e.g. restoring the gradient to exactly where it was when the user navigated away). Ignored ifseedis set.onPhaseUpdate(void Function(double)?): Called each tick with the current animation phase. Allows consumers to persist the phase value so they can later restore it viainitialPhase, or display a static gradient at the paused position usingseed.Example usage
Test plan
initialPhase: 5.0starts the gradient visually offset (not from 0)onPhaseUpdatefires each tick with increasing phase valuesseedis set🤖 Generated with Claude Code