flutter dart 错误 dart(argument_type_not_assignable)

flutter dart error dart(argument_type_not_assignable)

下面调用AnimationController的驱动函数导致报错信息:

The argument type 'ColorTween' can't be assigned to the parameter type 'Animatable'

Animation<Color> animation = animationController.drive(ColorTween(begin: Colors.red, end: colors.blue));

然而 ColorTween 是一个 Tween 而 Tween 是一个 Animatable。 我该如何解决这个错误?是个 '?'在颜色或 'dynamic' 之后 一个问题?显式转换也不起作用:

type 'ColorTween' is not a subtype of type 'Animatable<Color>' in type cast

flutter 2.0.4 dart 2.12.2

作业中 AnimationColor 类型缺少“?”因为 ColorTweenTween<Color?>.

这样试试:

TweenSequenceItem(
  weight: 1.0,
  tween: ColorTween(
    begin: Colors.black,
    end: Colors.lightBlue,
  ) as Animatable<Color>,
)