duytq94 / flutter-intro-slider

Simple and configurable app introduction slider for Flutter

Home Page:https://pub.dartlang.org/packages/intro_slider

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

in intro_slider_widget.dart, need to call super.dispose() at _end_ of dispose() function

mbevin opened this issue · comments

If super.dispose is at the start of the function (as currently) this can cause exceptions, as I did - see here for example https://stackoverflow.com/questions/58400001/should-i-call-super-initstate-at-the-end-or-at-the-beginning - it's precisely this mixin case that is what is the case in the code here and thus why it matters that super.dispose() needs to be at the end of the function, not the start.

An example of the kind of exception caused currently:

FlutterError (IntroSliderState#c8edc(ticker active) was disposed with an active Ticker.
IntroSliderState created a Ticker via its SingleTickerProviderStateMixin, but at the time dispose() was called on the mixin, that Ticker was still active. The Ticker 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:
  Ticker(created by IntroSliderState#c8edc)
  The stack trace when the Ticker 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      SingleTickerProviderStateMixin.createTicker (package:flutter/src/widgets/ticker_provider.dart:198:15)
  #3      new AnimationController.unbounded (package:flutter/src/animation/animation_controller.dart:279:21)
  #4      new TabController (package:flutter/src/material/tab_controller.dart:110:50)

Hi, very interesting, I haven't know about this issue.
Fixed. Many thanks to you.