Skip to content

[framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap - #195771

Merged
auto-submit[bot] merged 13 commits into
flutter:masterfrom
JiyadAhammad:fix-195744-draggable-sheet-snap-hold
Nov 24, 2026
Merged

auto-submit[bot] merged 13 commits into
flutter:masterfrom
JiyadAhammad:fix-195744-draggable-sheet-snap-hold

Conversation

@JiyadAhammad

Copy link
Copy Markdown
Contributor

Fixes #195744

Description

When a DraggableScrollableSheet with snap: true is in the middle of a snapping animation, touching the sheet starts a HoldScrollActivity via ScrollableState._handleDragDown. If the touch lifts without dragging, ScrollableState._handleDragCancel cancels the hold (_hold?.cancel()).

Because _shouldSnap() is true, _DraggableScrollableSheetScrollPosition.goBallistic intercepts ballistic simulations to manage snapping via its own AnimationController. While _dragCancelCallback was previously tracked and called for drag activities, _holdCancelCallback was never tracked or invoked. As a result, the HoldScrollActivity was never disposed, ScrollableState._disposeHold was never called, and ScrollableState._handleDragCancel failed assert(_hold == null).

This PR:

  • Adds _holdCancelCallback tracking and disposal to _DraggableScrollableSheetScrollPosition (mirroring _dragCancelCallback).
  • Overrides hold() to capture and clear the cancellation callback.
  • Disposes _holdCancelCallback in goBallistic() and handles position transfer in absorb().

Tests

  • Added regression test in packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart:
    A touch lifted while the sheet snaps does not assert _hold == null
  • Manual verification: Tested and verified on an iOS Simulator using a standalone sample app with DraggableScrollableSheet(snap: true) that tapping during snap and lifting without dragging no longer throws the assertion crash.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Nov 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces tracking for hold cancel callbacks in _DraggableScrollableSheetScrollPosition to prevent assertion failures when a touch is lifted while the sheet is snapping, and adds a corresponding regression test. The review feedback identifies that wrapping the drag and hold cancel callbacks to clear fields on cancellation introduces potential bugs during synchronous overrides and scroll position absorption, suggesting instead to pass the callbacks directly to the superclass methods.

@navaronbracke navaronbracke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions for the test

navaronbracke
navaronbracke previously approved these changes Nov 1, 2026

@victorsanni victorsanni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative design proposal

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 12, 2026
@victorsanni victorsanni added the CICD Run CI/CD label Nov 12, 2026
@JiyadAhammad

Copy link
Copy Markdown
Contributor Author

"Hi @victorsanni, quick question for my understanding — I noticed earlier that the Check Code Freeze check is showing 'Expected — Waiting for status to be reported'.

My understanding is that the code freeze is for Material and Cupertino changes, whereas this fix only modifies widgets/. Is there anything I need to do on my end to trigger or unblock this check, or is it just waiting on the GitHub Actions workflow permissions? Thanks!"

@navaronbracke navaronbracke added the CICD Run CI/CD label Nov 12, 2026
@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2026
@auto-submit

auto-submit Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/195771, Failed to enqueue flutter/flutter/195771 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

@JiyadAhammad

Copy link
Copy Markdown
Contributor Author

Hi @victorsanni and @navaronbracke ,

I noticed that the Auto-submit bot removed the autosubmit label because the required Check Code Freeze status check is still expected.

Since this PR only modifies the widgets/ directory and doesn't touch the Material or Cupertino directories covered by the code freeze, could you please advise how I can get this check triggered or unblocked?

Would pushing another commit be sufficient, or does this require any action from a maintainer?

Thanks for your time and guidance!

@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 23, 2026
@auto-submit

auto-submit Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/195771, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 23, 2026
@jmagman jmagman added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Nov 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into flutter:master with commit 4e67a90 Nov 24, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 25, 2026
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions)

flutter/flutter@b75c5b3...06f1c24

2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375)
2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371)
2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369)
2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364)
2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270)
2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219)
2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714)
2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965)
2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267)
2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363)
2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748)
2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596)
2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071)
2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351)
2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310)
2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266)
2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944)
2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918)
2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815)
2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229)
2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482)
2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300)
2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302)
2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004)
2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334)
2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333)
2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095)
2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355)
2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206)
2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771)
2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245)
2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563)
2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807)
2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316)
2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945)
2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309)
2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

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

Labels

CICD Run CI/CD f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DraggableScrollableSheet with snap: '_hold == null' assertion when a touch lifts during the snap

4 participants