Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
808 views
in Technique[技术] by (71.8m points)

flutter - Android Studio tells me "The argument type 'dynamic' can't be assigned to the parameter type 'double'."

This looks like a false positive to me because my Flutter App all still builds, and why couldn't I assign a dynamic to a double? But because now literally all of my files are red, I don't want to ignore it. There are also a LOT of other error messages, such as A value of type 'dynamic' can't be assigned to a variable of type 'String'., Missing type arguments for generic type 'MaterialPageRoute<dynamic>'. and many others that still work tho.

An example of code that doensn't work:

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()
);
}

Here, name and value are red with the errormessage from the title.

Things I tried

  • App restart
  • Android studio restart
  • Flutter clean
  • PC (Mac) restart

This happened after tortoise checkouting to an old revision and changing back.

Additionally, a lot of warnings appeard like only using " " if the string has ' ', or this: https://dart-lang.github.io/linter/lints/prefer_const_constructors.html

Flutter Version

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...