Skip to content

fix: cancel fade-out timer on dispose and guard reverse with mounted - #13

Open
codivo-erill wants to merge 1 commit into
hyperfluid-tech:mainfrom
codivo-erill:fix/fade-out-timer-after-dispose
Open

codivo-erill wants to merge 1 commit into
hyperfluid-tech:mainfrom
codivo-erill:fix/fade-out-timer-after-dispose

Conversation

@codivo-erill

Copy link
Copy Markdown

Problem

When a page containing a RoundScrollbar is closed within autoHideDuration (default 3 s) after the
user scrolled, the pending fade-out timer fires after the state was disposed and calls
_opacityController.reverse() on a disposed controller:

  • debug: AnimationController.reverse() called after AnimationController.dispose()
    (round_scrollbar.dart:172, from _RoundScrollbarState._maybeHideAfterDelay)
  • release: Null check operator used on a null value in AnimationController.stop (_ticker!.stop)

On Wear OS this happens all the time when rotating the crown in a list and then swiping back.

Fix

  • dispose() now cancels _fadeOutTimer.
  • The timer callback only calls reverse() while mounted, as a safety net.

This covers the same case as #12 and additionally cancels the timer, so nothing is left running after
dispose.

Tests

  • New widget test Lifecycle › GIVEN visible scrollbar WHEN it is disposed before the autoHide duration elapses THEN the pending fade-out does not touch the disposed controller.
    • Fails without the fix with the assertion above, passes with it.
  • flutter test: all 21 tests pass. flutter analyze: no issues.

Version

Bumped to 1.1.1 with a CHANGELOG entry.

Closing a page within the auto-hide duration after scrolling made the
pending fade-out timer call reverse() on the disposed opacity controller.

Bump version to 1.1.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant