[英]flutter dart error dart(argument_type_not_assignable)
The following call to the drive function of the AnimationController leads to the error message:以下对 AnimationController 的驱动 function 的调用导致错误消息:
The argument type 'ColorTween' can't be assigned to the parameter type 'Animatable'
参数类型“ColorTween”不能分配给参数类型“Animatable”
Animation<Color> animation = animationController.drive(ColorTween(begin: Colors.red, end: colors.blue));
Yet ColorTween is a Tween<Color?> and Tween<T extends dynamic> is an Animatable<T>.然而 ColorTween 是 Tween<Color?> 而 Tween<T extends dynamic> 是 Animatable<T>。 How can I fix this error?
我该如何解决这个错误? Is the '?'
是个 '?' after Color or 'dynamic' a problem?
在颜色或“动态”之后有问题吗? Explicit casting didn't work either:
显式转换也不起作用:
type 'ColorTween' is not a subtype of type 'Animatable<Color>' in type cast
类型“ColorTween”不是类型转换中“Animatable<Color>”类型的子类型
flutter 2.0.4
dart 2.12.2
flutter 2.0.4
dart 2.12.2
The Color
type of the Animation
in the assignment is missing the '?'作业中
Animation
的Color
类型缺少“?” as ColorTween
is a Tween<Color?>
.因为
ColorTween
是Tween<Color?>
。
Try like this:试试这样:
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(
begin: Colors.black,
end: Colors.lightBlue,
) as Animatable<Color>,
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.