这对我来说似乎是误报,因为我的 Flutter 应用程序仍在构建,为什么我不能为 double 分配动态?但是因为现在我的所有文件都是红色的,所以我不想忽略它。还有很多其他错误消息,例如 A value of type 'dynamic' can't be assigned to a variable of type 'String'.
、Missing type arguments for generic type 'MaterialPageRoute<dynamic>'.
和许多其他仍然有效的错误消息。
不起作用的代码示例:
class Kpi{
final String name;
final double value;
Kpi({this.type, this.name);
factory Kpi.valuesFromJson(Map<String, dynamic> json) {
return new Kpi(
name: json['Key'],
value: json['Value'].toDouble()
);
}
这里,名称和值是红色的,带有来自标题的错误消息。
我尝试过的东西
这是在乌龟检出旧版本并改回来之后发生的。
此外,如果字符串包含“”,则出现很多警告,例如只使用“”,或者这样:https://dart-lang.github.io/linter/lints/prefer_const_constructors.html
颤振版
Flutter 1.22.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f30b7f4db9 (3 months ago) • 2020-10-08 10:06:30 -0700
Engine • revision 75bef9f6c8
Tools • Dart 2.10.1