josiahsrc / dough

This package provides some widgets you can use to create a smooshy UI.
MIT License
703 stars 28 forks source link

'package:flutter/src/widgets/framework.dart': Failed assertion: line 4138 pos 12: '_debugLifecycleState != _ElementLifecycle.defunct': is not true. #3

Closed leidig54 closed 4 years ago

leidig54 commented 4 years ago

Hello. Am getting the above error when I pop the containing page. Am I doing something wrong?

Love the package otherwise, thanks!

════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown while finalizing the widget tree: _DoughState#6945b(ticker active) was disposed with an active Ticker.

_DoughState 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 _DoughState#6945b(lifecycle state: created)) The stack trace when the Ticker was actually created was:

0 new Ticker.

package:flutter/…/scheduler/ticker.dart:66

1 new Ticker

package:flutter/…/scheduler/ticker.dart:68

2 SingleTickerProviderStateMixin.createTicker

package:flutter/…/widgets/ticker_provider.dart:129

3 new AnimationController

package:flutter/…/animation/animation_controller.dart:247

4 _DoughState.initState

package:dough/dough.dart:47

5 StatefulElement._firstBuild

package:flutter/…/widgets/framework.dart:4640

6 ComponentElement.mount

package:flutter/…/widgets/framework.dart:4476 ... Normal element mounting (15 frames)

21 Element.inflateWidget

package:flutter/…/widgets/framework.dart:3446

22 MultiChildRenderObjectElement.mount

package:flutter/…/widgets/framework.dart:5947

23 Element.inflateWidget

package:flutter/…/widgets/framework.dart:3446

24 Element.updateChild

package:flutter/…/widgets/framework.dart:3211

25 ComponentElement.performRebuild

package:flutter/…/widgets/framework.dart:4527

26 StatefulElement.performRebuild

package:flutter/…/widgets/framework.dart:4675

27 Element.rebuild

package:flutter/…/widgets/framework.dart:4218

28 BuildOwner.buildScope

package:flutter/…/widgets/framework.dart:2627

29 WidgetsBinding.drawFrame

package:flutter/…/widgets/binding.dart:883

30 RendererBinding._handlePersistentFrameCallback

package:flutter/…/rendering/binding.dart:284

31 SchedulerBinding._invokeFrameCallback

package:flutter/…/scheduler/binding.dart:1113

32 SchedulerBinding.handleDrawFrame

package:flutter/…/scheduler/binding.dart:1052

33 SchedulerBinding._handleDrawFrame

package:flutter/…/scheduler/binding.dart:968

37 _invoke (dart:ui/hooks.dart:261:10)

38 _drawFrame (dart:ui/hooks.dart:219:3)

(elided 3 frames from dart:async)

When the exception was thrown, this was the stack

0 SingleTickerProviderStateMixin.dispose.

package:flutter/…/widgets/ticker_provider.dart:142

1 SingleTickerProviderStateMixin.dispose

package:flutter/…/widgets/ticker_provider.dart:156

2 _DoughState.dispose

package:dough/dough.dart:60

3 StatefulElement.unmount

package:flutter/…/widgets/framework.dart:4729

4 _InactiveElements._unmount

package:flutter/…/widgets/framework.dart:1922

leidig54 commented 4 years ago

Could using this on the same page be the cause?

https://pub.dev/packages/animated_background

josiahsrc commented 4 years ago

Just looked into this, I believe the issue was that the animation controller for the dough widget was being disposed after its parent ticker was disposed. I just published a new version 0.0.5, could you pull this down and see if this fixes the issue?

leidig54 commented 4 years ago

Just tried the new version, now working flawlessly for me. Thanks for your help :)

josiahsrc commented 4 years ago

Perfect :) No problem!