【发布时间】:2021-09-08 13:58:12
【问题描述】:
我正在尝试将我的应用程序更新到 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 后,我对新语法感到困惑,当我转到文档时我卡住了https://pub.dev/packages/sa_multi_tween,它说没有其他需要被改变。这显然不是真的,我的曲目也不再被识别。
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)
我正在努力查看我需要更改什么以满足新语法,任何帮助将不胜感激。
【问题讨论】:
标签: flutter flutter-dependencies flutter-animation flutter-upgrade