Skip to content

Assertion Error using CustomScrollView with CupertinoSliverNavigationBar (Flutter 3.29) #163297

@bobekos

Description

@bobekos

Steps to reproduce

When scrolling on the CupertinoSliverNavigationBar, an assertion error occurs randomly. The issue arises after performing multiple scroll gestures on the navigation bar in both directions. The following assertion errors are thrown:

'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 875 pos 12: '_hold == null': is not true.
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 880 pos 12: '_hold == null || _drag == null': is not true.

Steps to Reproduce:

  1. Run the provided code.
  2. Scroll up or down on the navigation bar multiple times.
  3. Observe the assertion errors in the debug console.
  4. Attempt to scroll again—scrolling is now completely broken.

Code:

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: Scaffold(
        body: CustomScrollView(
          slivers: [
            CupertinoSliverNavigationBar(
                largeTitle: Text("Example"),
            ),
          ],
        ),
      ),
    );
  }
}

Expected results

Regardless of the scrolling movement, no errors should be thrown.

Actual results

Assertion errors occur, and the scrolling state becomes unresponsive.

Code sample

Example
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: Scaffold(
        body: CustomScrollView(
          slivers: [
            CupertinoSliverNavigationBar(
                largeTitle: Text("Example"),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
413289971-3b229b1f-37b1-418d-9fbd-dc95be1ec686.mov

Logs

Logs
======== Exception caught by gesture ===============================================================
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 875 pos 12: '_hold == null': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack: 
#2      ScrollableState._handleDragStart (package:flutter/src/widgets/scrollable.dart:875:12)
#3      DragGestureRecognizer._checkStart.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:849:53)
#4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:357:24)
#5      DragGestureRecognizer._checkStart (package:flutter/src/gestures/monodrag.dart:849:7)
#6      DragGestureRecognizer._checkDrag (package:flutter/src/gestures/monodrag.dart:815:5)
#7      DragGestureRecognizer.acceptGesture (package:flutter/src/gestures/monodrag.dart:743:7)
#8      GestureArenaManager._resolveByDefault (package:flutter/src/gestures/arena.dart:275:25)
#9      GestureArenaManager._tryToResolveArena.<anonymous closure> (package:flutter/src/gestures/arena.dart:255:31)
(elided 4 frames from class _AssertionError and dart:async)
Handler: "onStart"
Recognizer: VerticalDragGestureRecognizer#42451
  start behavior: start
====================================================================================================

======== Exception caught by gesture ===============================================================
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 880 pos 12: '_hold == null || _drag == null': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack: 
#2      ScrollableState._handleDragUpdate (package:flutter/src/widgets/scrollable.dart:880:12)
#3      DragGestureRecognizer._checkUpdate.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:868:55)
#4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:357:24)
#5      DragGestureRecognizer._checkUpdate (package:flutter/src/gestures/monodrag.dart:868:7)
#6      DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:714:11)
#7      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:97:12)
#8      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#9      _LinkedHashMapMixin.forEach (dart:_compact_hash:763:13)
#10     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#11     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:131:7)
#12     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:530:19)
#13     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:499:22)
#14     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:460:11)
#15     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:437:7)
#16     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:394:5)
#17     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:341:7)
#18     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:308:9)
#19     _invoke1 (dart:ui/hooks.dart:332:13)
#20     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:451:7)
#21     _dispatchPointerDataPacket (dart:ui/hooks.dart:267:31)
(elided 2 frames from class _AssertionError)
Handler: "onUpdate"
Recognizer: VerticalDragGestureRecognizer#42451
  start behavior: start
====================================================================================================

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.3 24D60 darwin-arm64, locale de-DE) [1.836ms]
    • Flutter version 3.29.0 on channel stable at /Users/***
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35c388afb5 (4 days ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the consolef: cupertinoflutter/packages/flutter/cupertino repositoryf: scrollingViewports, list views, slivers, etc.found in release: 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions