Я создал свой диалог с анимацией. Это виджет диалога.
loadingDialog(BuildContext context,AnimationController controller) {
return showDialog(
barrierDismissible: false,
context: context,
child: AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(9.0)),
backgroundColor: Colors.grey[300],
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
loader(context, controller),
SizedBox(
height: 8.0,
),
Text("Loading..."),
],
),
));
}
это загрузчик, который включает анимацию
loader(BuildContext context, AnimationController controller){
return Container(
// color: Colors.deepOrangeAccent,
height: SizeConfig.safeBlockVertical * 8,
width: SizeConfig.safeBlockVertical * 6,
child: Stack(
children: <Widget>[
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
child: RotationTransition(
turns: Tween(begin: 0.0, end: 1.0)
.animate(controller),
child: Image.asset("images/gear.png",
color: Color(Styles().blueSamruddhiColorDark),),
),
),
],
),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
child: Image.asset("images/hat.png",
),
),
],
),
],
),
);
}
таким образом, контроллер анимации запускается ...
AnimationController _controller;
@override
void didChangeDependencies() {
_controller = AnimationController(
duration: const Duration(milliseconds: 5000),
vsync: this,
);
_controller.repeat();
super.didChangeDependencies();
}
Я также разместил контроллер анимации ...
@override
void dispose() {
_controller?.dispose();
super.dispose();
}
в диалоге загрузки во второй раз, выдает мне следующее исключение и экран становится черным> M я что-то делаю не так ????
I/flutter ( 8929): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 8929): The following assertion was thrown while finalizing the widget tree:
I/flutter ( 8929): _LoginScreenState#94277(tickers: tracking 6 tickers) was disposed with an active Ticker.
I/flutter ( 8929): _LoginScreenState created a Ticker via its TickerProviderStateMixin, but at the time dispose() was
I/flutter ( 8929): called on the mixin, that Ticker was still active. All Tickers must be disposed before calling
I/flutter ( 8929): super.dispose().
I/flutter ( 8929): Tickers used by AnimationControllers should be disposed by calling dispose() on the
I/flutter ( 8929): AnimationController itself. Otherwise, the ticker will leak.
I/flutter ( 8929): The offending ticker was:
I/flutter ( 8929): _WidgetTicker(created by _LoginScreenState#94277(lifecycle state: initialized, tickers: tracking 0
I/flutter ( 8929): tickers))
I/flutter ( 8929): The stack trace when the _WidgetTicker was actually created was:
I/flutter ( 8929): #0 new Ticker.<anonymous closure> (package:flutter/src/scheduler/ticker.dart:66:40)
I/flutter ( 8929): #1 new Ticker (package:flutter/src/scheduler/ticker.dart:68:6)
I/flutter ( 8929): #2 new _WidgetTicker (package:flutter/src/widgets/ticker_provider.dart:271:80)
I/flutter ( 8929): #3 TickerProviderStateMixin.createTicker
I/flutter ( 8929): (package:flutter/src/widgets/ticker_provider.dart:202:34)
I/flutter ( 8929): #4 new AnimationController (package:flutter/src/animation/animation_controller.dart:247:21)
I/flutter ( 8929): #5 _LoginScreenState.didChangeDependencies
I/flutter ( 8929): (package:samruddhiclient/screens/login_screen.dart:60:19)
I/flutter ( 8929): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4665:12)
I/flutter ( 8929): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4480:5)
I/flutter ( 8929): ... Normal element mounting (141 frames)
I/flutter ( 8929): #148 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3450:14)
I/flutter ( 8929): #149 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5951:32)
I/flutter ( 8929): ... Normal element mounting (248 frames)
I/flutter ( 8929): #397 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3450:14)
I/flutter ( 8929): #398 Element.updateChild (package:flutter/src/widgets/framework.dart:3218:18)
I/flutter ( 8929): #399 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1129:16)
I/flutter ( 8929): #400 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1100:5)
I/flutter ( 8929): #401 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure>
I/flutter ( 8929): (package:flutter/src/widgets/binding.dart:1042:17)
I/flutter ( 8929): #402 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2607:19)
I/flutter ( 8929): #403 RenderObjectToWidgetAdapter.attachToRenderTree
I/flutter ( 8929): (package:flutter/src/widgets/binding.dart:1041:13)
I/flutter ( 8929): #404 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:922:7)
I/flutter ( 8929): #405 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure>
I/flutter ( 8929): (package:flutter/src/widgets/binding.dart:903:7)
I/flutter ( 8929): (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
I/flutter ( 8929): When the exception was thrown, this was the stack:
I/flutter ( 8929): #0 TickerProviderStateMixin.dispose.<anonymous closure> (package:flutter/src/widgets/ticker_provider.dart:219:13
)
I/flutter ( 8929): #1 TickerProviderStateMixin.dispose (package:flutter/src/widgets/ticker_provider.dart:237:6)
I/flutter ( 8929): #2 _LoginScreenState.dispose (package:samruddhiclient/screens/login_screen.dart:78:11)
I/flutter ( 8929): #3 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4733:12)
I/flutter ( 8929): #4 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1922:13)
I/flutter ( 8929): #5 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #6 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #7 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #8 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #9 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #10 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #11 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #12 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #13 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #14 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #15 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #16 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #17 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #18 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #19 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #20 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #21 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #22 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #23 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #24 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #25 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #26 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #27 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #28 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #29 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #30 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #31 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #32 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #33 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #34 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #35 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #36 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #37 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #38 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #39 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #40 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #41 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #42 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #43 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #44 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #45 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #46 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #47 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #48 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #49 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #50 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #51 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #52 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #53 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #54 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #55 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #56 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #57 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #58 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #59 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #60 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #61 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #62 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #63 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #64 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #65 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #66 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5821:14)
I/flutter ( 8929): #67 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #68 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #69 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #70 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #71 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #72 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #73 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #74 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #75 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #76 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #77 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #78 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #79 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #80 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1920:7)
I/flutter ( 8929): #81 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4560:14)
I/flutter ( 8929): #82 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
I/flutter ( 8929): #83 ListIterable.forEach (dart:_internal/iterable.dart:41:13)
I/flutter ( 8929): #84 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1931:25)
I/flutter ( 8929): #85 BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2714:27)
I/flutter ( 8929): #86 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2545:15)
I/flutter ( 8929): #87 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2713:7)
I/flutter ( 8929): #88 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:866:18)
I/flutter ( 8929): #89 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:284:5)
I/flutter ( 8929): #90 _Closure.call (dart:core-patch/function.dart)
I/flutter ( 8929): #91 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1074:15)
I/flutter ( 8929): #92 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1013:9)
I/flutter ( 8929): #93 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:929:5)
I/flutter ( 8929): #97 _invoke (dart:ui/hooks.dart:277:10)
I/flutter ( 8929): #98 _drawFrame (dart:ui/hooks.dart:235:3)
I/flutter ( 8929): (elided 3 frames from dart:async)
I/flutter ( 8929): ════════════════════════════════════════════════════════════════════════════════════════════════════