@@ -63,6 +63,7 @@ extension AnimatedEffectExt on Widget? {
6363 int repeat = 0 ,
6464 bool reverse = false ,
6565 bool startImmediately = false ,
66+ bool skipFirstTime = false ,
6667 bool resetValues = false ,
6768 bool waitForLastAnimation = false ,
6869 Duration delay = Duration .zero,
@@ -78,6 +79,7 @@ extension AnimatedEffectExt on Widget? {
7879 repeat: repeat,
7980 reverse: reverse,
8081 startImmediately: startImmediately,
82+ skipFirstTime: skipFirstTime,
8183 resetValues: resetValues,
8284 waitForLastAnimation: waitForLastAnimation,
8385 delay: delay,
@@ -261,6 +263,8 @@ class AnimatedEffect extends StatefulWidget {
261263 /// built, ignoring the value of [trigger] initially.
262264 final bool startImmediately;
263265
266+ final bool skipFirstTime;
267+
264268 /// Normally, an effect represents the current state of the widget and this
265269 /// animate effect is only in charge of lerping between states of those
266270 /// effect values.
@@ -301,6 +305,7 @@ class AnimatedEffect extends StatefulWidget {
301305 this .repeat = 0 ,
302306 this .reverse = false ,
303307 this .startImmediately = false ,
308+ this .skipFirstTime = false ,
304309 this .resetValues = false ,
305310 this .waitForLastAnimation = false ,
306311 this .delay = Duration .zero,
@@ -334,7 +339,7 @@ class AnimatedEffectState extends State<AnimatedEffect>
334339 /// The animation controller that drives the animation.
335340 late final AnimationController controller = AnimationController (
336341 vsync: this ,
337- value: shouldSkip ? 1 : 0 ,
342+ value: widget.skipFirstTime || shouldSkip ? 1 : 0 ,
338343 duration: widget.duration,
339344 );
340345
@@ -426,7 +431,7 @@ class AnimatedEffectState extends State<AnimatedEffect>
426431 // ancestor's [AnimationTriggerType] is
427432 // [AnimationTriggerType.afterLast].
428433 final AnimatedEffectState ? parentState =
429- context.findAncestorStateOfType <AnimatedEffectState >();
434+ context.findAncestorStateOfType <AnimatedEffectState >();
430435 final AnimationTriggerType ? triggerType =
431436 parentState? .widget.triggerType;
432437 if (parentState != null &&
@@ -438,7 +443,7 @@ class AnimatedEffectState extends State<AnimatedEffect>
438443 // [ResetAllAnimationsEffect], reset all animations in the chain.
439444 else {
440445 final resetState =
441- context.findAncestorStateOfType <ResetAllAnimationsEffectState >();
446+ context.findAncestorStateOfType <ResetAllAnimationsEffectState >();
442447 resetState? .reset ();
443448 }
444449 }
@@ -495,15 +500,16 @@ class AnimatedEffectState extends State<AnimatedEffect>
495500 Widget build (BuildContext context) {
496501 return AnimatedBuilder (
497502 animation: controller,
498- builder: (context, child) => EffectQuery (
499- linearValue: controller.value,
500- curvedValue: widget.curve.transform (controller.value),
501- isTransition: false ,
502- resetValues: widget.resetValues,
503- duration: widget.duration,
504- curve: widget.curve,
505- child: child! ,
506- ),
503+ builder: (context, child) =>
504+ EffectQuery (
505+ linearValue: controller.value,
506+ curvedValue: widget.curve.transform (controller.value),
507+ isTransition: false ,
508+ resetValues: widget.resetValues,
509+ duration: widget.duration,
510+ curve: widget.curve,
511+ child: child! ,
512+ ),
507513 child: widget.child,
508514 );
509515 }
0 commit comments