Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

No dispose method to dispose the ScrollablePositionedList controller #255

@flutternoob

Description

@flutternoob

Problem description

Steps to reproduce

I tried calling .dispose() on the itemController ItemScrollController, but could not find a dispose() method. If I switch between screens during a very slow scroll (for eg., 2 minutes), I get an error. I checked the API reference and could not find any information on how to dispose the controller. Is there a work around to disposing the controller?

Expected behavior

Expected the controller to dispose

Actual behavior

Error while changing between screens:

The following assertion was thrown while finalizing the widget tree:
_ScrollablePositionedListState#0854d(tickers: tracking 1 ticker) was disposed with an active Ticker.

_ScrollablePositionedListState created a Ticker via its TickerProviderStateMixin, but at the time dispose() was called on the mixin, that Ticker was still active. All Tickers must be disposed before calling super.dispose().

Tickers used by AnimationControllers should be disposed by calling dispose() on the AnimationController itself. Otherwise, the ticker will leak.

The offending ticker was: _WidgetTicker(created by _ScrollablePositionedListState#0854d(tickers: tracking 0 tickers))
The stack trace when the _WidgetTicker was actually created was:
#0      new Ticker.<anonymous closure> (package:flutter/src/scheduler/ticker.dart:67:40)
#1      new Ticker (package:flutter/src/scheduler/ticker.dart:69:6)
#2      new _WidgetTicker (package:flutter/src/widgets/ticker_provider.dart:271:81)
#3      TickerProviderStateMixin.createTicker (package:flutter/src/widgets/ticker_provider.dart:202:34)
#4      new AnimationController (package:flutter/src/animation/animation_controller.dart:247:21)
#5      _ScrollablePositionedListState._startScroll.<anonymous closure>.<anonymous closure> (package:scrollable_positioned_list/src/scrollable_positioned_list.dart:477:15)
#6      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#7      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1090:9)
#8      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:998:5)
#12     _invoke (dart:ui/hooks.dart:161:10)
#13     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:253:5)
#14     _drawFrame (dart:ui/hooks.dart:120:31)
(elided 3 frames from dart:async)

When the exception was thrown, this was the stack: 
#0      TickerProviderStateMixin.dispose.<anonymous closure> (package:flutter/src/widgets/ticker_provider.dart:219:13)
#1      TickerProviderStateMixin.dispose (package:flutter/src/widgets/ticker_provider.dart:237:6)
#2      _ScrollablePositionedListState.dispose (package:scrollable_positioned_list/src/scrollable_positioned_list.dart:290:11)
#3      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4721:11)

Environment

[√] Flutter (Channel stable, 2.0.5, on Microsoft Windows [Version 10.0.19042.928], locale en-IN)
    • Flutter version 2.0.5 at c:\src\flutter
    • Framework revision adc687823a (2 weeks ago), 2021-04-16 09:40:20 -0700
    • Engine revision b09f014e96
    • Dart version 2.12.3

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Ankush\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code, 64-bit edition (version 1.54.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.21.0

[√] Connected device (3 available)
    • SM A205F (mobile) • RZ8M92CX7PJ • android-arm64  • Android 10 (API 29)
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 90.0.4430.93
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 90.0.818.51

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions