Skip to content

[Bug report] ScrollController was used after being disposed #170

Description

@MichalNemec

Version

6.2.1

Platforms

iOS

Device Model

iPhone 16(iOS 18.0)

flutter info

[✓] Flutter (Channel stable, 3.38.5, on macOS 14.6.1 23G93 darwin-arm64, locale en-US) [1,463ms]
    • Flutter version 3.38.5 on channel stable at /opt/homebrew/share/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f6ff1529fd (6 weeks ago), 2025-12-11 11:50:07 -0500
    • Engine revision 1527ae0ec5
    • Dart version 3.10.4
    • DevTools version 2.51.1
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [5.2s]
    • Android SDK at /Users/user/Library/Android/sdk
    • Emulator version 34.1.19.0 (build_id 11525734) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1) [2.1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [7ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (3 available) [11.8s]
    • iPhone 16 (mobile)         • 4C554B2A-887F-4AB4-9002-EB2039010E3C • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 139.0.7258.139

[✓] Network resources [592ms]
    • All expected network resources are available.

• No issues found!

How to reproduce?

  • Accessing screen where extended_nested_scroll_view is used
  • clicking on child
  • navigating back
  • scroll down
  • see error

Logs

════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for _ExtendedNestedScrollPosition:
A ScrollController was used after being disposed.
Once you have called dispose() on a ScrollController, it can no longer be used.

When the exception was thrown, this was the stack:
#0      ChangeNotifier.debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:182:9)
change_notifier.dart:182
#1      ChangeNotifier.debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:189:6)
change_notifier.dart:189
#2      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:414:27)
change_notifier.dart:414
#3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:435:24)
change_notifier.dart:435
#4      ScrollPosition.notifyListeners (package:flutter/src/widgets/scroll_position.dart:1123:11)
scroll_position.dart:1123
#5      ScrollPosition.setPixels (package:flutter/src/widgets/scroll_position.dart:392:9)
scroll_position.dart:392
#6      BallisticScrollActivity.applyMoveTo (package:flutter/src/widgets/scroll_activity.dart:634:21)
scroll_activity.dart:634
#7      _NestedOuterBallisticScrollActivity.applyMoveTo (package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart:1758:31)
extended_nested_scroll_view.dart:1758
#8      BallisticScrollActivity._tick (package:flutter/src/widgets/scroll_activity.dart:620:10)
scroll_activity.dart:620
#9      AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:160:19)
listener_helpers.dart:160
#10     AnimationController._tick (package:flutter/src/animation/animation_controller.dart:957:5)
animation_controller.dart:957
#11     Ticker._tick (package:flutter/src/scheduler/ticker.dart:269:12)
ticker.dart:269
#12     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1434:15)
binding.dart:1434
#13     SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1265:11)
binding.dart:1265
#14     _LinkedHashMapMixin.forEach (dart:_compact_hash:765:13)
#15     SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:1263:17)
binding.dart:1263
#16     SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:1179:5)
binding.dart:1179
#17     _invoke1 (dart:ui/hooks.dart:372:13)
hooks.dart:372
#18     PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:426:5)
platform_dispatcher.dart:426
#19     _beginFrame (dart:ui/hooks.dart:317:31)
hooks.dart:317

The _ExtendedNestedScrollPosition sending notification was: _ExtendedNestedScrollPosition#49bc4(outer, offset: 101.7, range: 0.0..141.6, viewport: 852.0)
════════════════════════════════════════════════════════════════════════════════

Example code (optional)

ExtendedNestedScrollView(
      floatHeaderSlivers: false,
      controller: CommunityScrollController().scrollController,
      physics: const NeverScrollableScrollPhysics(),
      headerSliverBuilder: (context, innerBoxIsScrolled) => [
        SliverOverlapAbsorber(
          handle: ExtendedNestedScrollView.sliverOverlapAbsorberHandleFor(context),
...

include tabbar
...
TabBarView(
        controller: _tabController,
        physics: const NeverScrollableScrollPhysics(),
        children: pages,
      ),

---
Each child page has this as a frame:

RefreshIndicator.adaptive(
      displacement: _displacement,
      triggerMode: RefreshIndicatorTriggerMode.onEdge,
      onRefresh: () => Future.sync(() {
        return _pagination.refresh();
      }),
      child: CustomScrollView(
        scrollBehavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
        key: const PageStorageKey('x'),
        restorationId: 'x',
        physics: const AlwaysScrollableScrollPhysics(),
        slivers: [
...

Contact

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions