标签: animationcontroller

AnimationController 未定义命名参数“vsync”

AnimationController 停止工作,因为不知何故 vsync 不再是命名参数。

这行代码停止工作。

controller = AnimationController(duration: Duration(seconds: 3), vsync: this);

它现在显示一个错误说:

The named parameter 'vsync' isn't defined.
Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'vsync'.dartundefined_named_parameter
Run Code Online (Sandbox Code Playgroud)

我在两个不同的应用程序中使用了这个完全相同的代码,在其中一个应用程序中我只是删除了淡入淡出的文本动画作为热修复,但在另一个应用程序中我需要一个真正的修复。最近有人看到这个问题吗?

笔记:

- 这个完全相同的代码已经工作了几个月,但在更新后停止工作。

- 周围的班级确实有: with TickerProviderStateMixin

class FadingText extends StatefulWidget {
  final String text;
  final int seconds;
  final TextStyle style;

  FadingText({this.text, this.seconds, this.style});

  @override
  _FadingTextState createState() => _FadingTextState();
}

class _FadingTextState extends State<FadingText> with TickerProviderStateMixin {
  AnimationController controller;
  Animation animation; …
Run Code Online (Sandbox Code Playgroud)

dart flutter animationcontroller

77
推荐指数
7
解决办法
3万
查看次数

如何在 Flutter 中的 AnimationController.repeat() 之间添加一些延迟

我需要在每次动画迭代之间添加一些延迟来调用重复。类似于下图。 在此处输入图片说明

我试图通过将值传递给 repeat 方法的 period 参数来做到这一点,但这不是我所期望的。

_controller = AnimationController(vsync: this, duration: widget.period)
      ..addStatusListener((AnimationStatus status) {
        if (status != AnimationStatus.completed) {
          return;
        }
        _count++;
        if (widget.loop <= 0) {
          //_controller.repeat(period: Duration(microseconds: 5000));
          _controller.repeat();
        } else if (_count < widget.loop) {
          _controller.forward(from: 0.0);
        }
      });
Run Code Online (Sandbox Code Playgroud)

我还尝试在动画中添加 Tween。那也没有帮助。你能帮我澄清一下我哪里出错了吗?

AnimatedBuilder(
      animation: Tween<double>(begin: 0.0, end: 1.0).animate(
        CurvedAnimation(
          parent: _controller,
          curve: Interval(0.5, 1.0)
        ),
      ),
      child: widget.child,
      builder: (BuildContext context, Widget child) => _Shiner(
        child: child,
        direction: widget.direction,
        gradient: widget.gradient,
        percent: _controller.value,
        enabled: widget.enabled,
      ),
    );
Run Code Online (Sandbox Code Playgroud)

animation delay flutter flutter-animation animationcontroller

5
推荐指数
1
解决办法
2713
查看次数

如何在flutter中播放特定时间段的lottie动画

我想在颤振中播放特定时间的洛蒂动画。我不想通过快进来播放它。就像如果我的动画包含总计90 frames那么如果我只想先播放30 frames那么我可以实现这一点吗?或者像如果我的动画总共有 2 秒但我只想播放第一秒。那么我该如何使用动画控制器或任何其他东西来做到这一点?

flutter lottie flutter-animation animationcontroller

2
推荐指数
1
解决办法
1万
查看次数

Flutter 2.2.3:参数类型“Animation&lt;dynamic&gt;”无法分配给参数类型“Animation&lt;double&gt;”

我尝试从中传递列表位置并收到此错误:参数类型“动画”​​无法分配给参数类型“动画”​​。我按照 YouTube 用户的步骤操作,可以在此处查看完整代码: https: //github.com/codespiration/petadoption/blob/master/menu_frame.dart。真的很感谢你们的帮助

> @override   void initState() {
>     super.initState();
>     _animationController = AnimationController(vsync: this, duration: duration);
>     scaleAnimation =
>         Tween<double>(begin: 1.0, end: 0.6).animate(_animationController);
>     smallerScaleAnimation =
>         Tween<double>(begin: 1.0, end: 0.5).animate(_animationController);
> 
>     scaleAnimations = [
>       Tween<double>(begin: 1.0, end: 0.7).animate(_animationController),
>       Tween<double>(begin: 1.0, end: 0.6).animate(_animationController),
>       Tween<double>(begin: 1.0, end: 0.5).animate(_animationController),
>     ];
>     _animationController.forward();   }
> 
> Widget buildScreenStack(int position) {
>     final deviceWidth = MediaQuery.of(context).size.width;
>     return AnimatedPositioned(
>       duration: duration,
>       top: …
Run Code Online (Sandbox Code Playgroud)

dart flutter animationcontroller

1
推荐指数
1
解决办法
4913
查看次数

参数类型“_ProfileImageState”无法分配给参数类型“TickerProvider”

主要目标是允许用户从图库/相机中选择图像,但为了使事情看起来不错,使用了一些动画并设计了整个图像拾取对话框

class _ProfileImageState extends State<ProfileImage>{

      @override

      File _image;

      //ImagePickerHandler imagePicker;

      @override
      void initState() {

        super.initState();
//initiating to start so that transition from one state to another is smooth
 
        var _controller = new AnimationController(
          vsync: this,
          duration: const Duration(milliseconds: 500),
        );


        imagePicker=new ImagePickerHandler(this.userImage(_image));


      }
Run Code Online (Sandbox Code Playgroud)

flutter animationcontroller

1
推荐指数
1
解决办法
3664
查看次数