简体   繁体   English

flutter dart 错误飞镖(argument_type_not_assignable)

[英]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 '?'作业中AnimationColor类型缺少“?” as ColorTween is a Tween<Color?> .因为ColorTweenTween<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.

相关问题 错误:[dart] 无法将参数类型“Context”分配给参数类型“BuildContext”。 [argument_type_not_assignable] - error: [dart] The argument type 'Context' can't be assigned to the parameter type 'BuildContext'. [argument_type_not_assignable] 参数类型'列表<string> ' 不能分配给 Dart 上的参数类型 'String'.dart(argument_type_not_assignable)</string> - The argument type 'List<String>' can't be assigned to the parameter type 'String'.dart(argument_type_not_assignable) on the Dart 不能将参数类型“String”分配给参数类型“Route”<Object?> &#39;.dart(argument_type_not_assignable) - The argument type 'String' can't be assigned to the parameter type 'Route<Object?>'.dart(argument_type_not_assignable) 参数类型 &#39;Null&#39; 不能分配给参数类型 &#39;FirebaseUser&#39;.dart(argument_type_not_assignable) - The argument type 'Null' can't be assigned to the parameter type 'FirebaseUser'.dart(argument_type_not_assignable) 不能将参数类型“Book”分配给参数类型“Map”<String, dynamic> &#39;.dart(argument_type_not_assignable) - The argument type 'Book' can't be assigned to the parameter type 'Map<String, dynamic>'.dart(argument_type_not_assignable) 错误:参数类型“用户?” 不能分配给参数类型“用户”。 (argument_type_not_assignable 在 [food_app] lib\auth\sign_in.dart:36) - error: The argument type 'User?' can't be assigned to the parameter type 'User'. (argument_type_not_assignable at [food_app] lib\auth\sign_in.dart:36) 如何解决“参数类型‘对象?’ 不能分配给参数类型 'String'.dart(argument_type_not_assignable)”? - How can I resolve "The argument type 'Object?' can't be assigned to the parameter type 'String'.dart(argument_type_not_assignable)"? 颤振/飞镖列错误的必需参数 - required argument on Column error on flutter/dart Flutter / Dart 错误:无法将参数类型“Null Function(Key)”分配给参数类型“void Function(Object)” - Flutter / Dart Error: The argument type 'Null Function(Key)' can't be assigned to the parameter type 'void Function(Object)' flutter / dart 错误:参数类型 'Future<file> ' 不能分配给参数类型 'File'</file> - flutter / dart error: The argument type 'Future<File>' can't be assigned to the parameter type 'File'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM