overscroll_pop icon indicating copy to clipboard operation
overscroll_pop copied to clipboard

fix: ticker dispose problem while enable passing false

Open SalihCanBinboga opened this issue 1 year ago • 3 comments
trafficstars

Exception:

Looking up a deactivated widget's ancestor is unsafe. At this point the state of the widget's element tree is no longer stable. To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.

StatefulElement#04b6c(DEFUNCT)(no widget, state: _OverscrollPopState#dc799(ticker inactive))

** We are preventing unnecessary ticker creation with this PR.

SalihCanBinboga avatar Aug 17 '24 08:08 SalihCanBinboga

@SalihCanBinboga Need to check didUpdateWidget in case widget.enable is changed. Anyway, I fixed it different way, you can have a look at latest code. Thank you.

luunc avatar Aug 17 '24 09:08 luunc

@SalihCanBinboga Need to check didUpdateWidget in case widget.enable is changed. Anyway, I fixed it different way, you can have a look at latest code. Thank you.

Hey, first of all thank you quick answering and at the initState stage, if the animation controller is not created when enabled is false, it will prevent the creation of a ticker, which in turn will avoid unnecessary memory usage when the screen is opened. Initializing it based on the enabled check will be more beneficial for performance. Therefore, I recommend preventing unnecessary initialization. @luunc

SalihCanBinboga avatar Aug 17 '24 10:08 SalihCanBinboga

@SalihCanBinboga , I understand your concern. However, can you try setting enable from false to true and move the widget around to pop a route to see what may happen? That might be a bigger bug.

luunc avatar Aug 20 '24 02:08 luunc