Flutter simple_animation 迁移

问题描述

我正在尝试将我的应用程序更新为 Flutter 2.0,但我坚持使用已弃用的动画。 我的 FadeIn.dart 文件中存在一些错误,该文件管理我在其他几个地方使用的类来淡入和淡出向用户发送的通知和警报。

这是我在文件中流行的代码

import 'package:Flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';

class FadeIn extends StatelessWidget {
  final double delay;
  final Widget child;

  FadeIn(this.delay,this.child);

  @override
  Widget build(BuildContext context) {
    final tween = MultiTrackTween([
      Track("opacity")
          .add(Duration(milliseconds: 500),Tween(begin: 0.0,end: 1.0)),Track("translateX").add(
          Duration(milliseconds: 500),Tween(begin: 50.0,end: 0.0),curve: Curves.eaSEOut)
    ]);

    return CustomAnimation(
      delay: Duration(milliseconds: (300 * delay).round()),duration: tween.duration,tween: tween,child: child,builderWithChild: (context,child,animation) =>
          Opacity(
            opacity: animation["opacity"],child: Transform.translate(
                offset: Offset(animation["translateX"],0),child: child),),);
  }
}

我正在查看 https://pub.dev/documentation/simple_animations/latest/https://pub.dev/packages/sa_v1_migration/versions/1.1.2,但在我转到文档时更改为 MultiTween 后,我对新语法感到困惑{{3}它说没有其他需要改变的。这显然不是真的,我的曲目也不再被识别。

Flutter 错误消息。

error: The method 'MultiTrackTween' isn't defined for the type 'FadeIn'. (undefined_method at [orange_power] lib/component/FadeIn.dart:12)
error: The method 'Track' isn't defined for the type 'FadeIn'. (undefined_method at [orange_power] lib/component/FadeIn.dart:13)
error: The method 'Track' isn't defined for the type 'FadeIn'. (undefined_method at [orange_power] lib/component/FadeIn.dart:15)
warning: The parameter 'builder' is required. (missing_required_param at [orange_power] lib/component/FadeIn.dart:20)
error: The named parameter 'builderWithChild' isn't defined. (undefined_named_parameter at [orange_power] lib/component/FadeIn.dart:25)

我正在努力了解我需要更改哪些内容以满足新语法,任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...