起初,当我设置我的 flutter 项目(第一个默认 flutter 文件。按下按钮并递增数字)时,它仅在 chrome 中完美运行,而不是在 Android 虚拟模拟器中运行,但在某些时候它停止运行。现在,当我在 VS Code 中运行它时,它也不会在 chrome 中运行。 尝试一次又一次地从头开始创建该项目。但仍然面临同样的问题。
这是 VS Code 的调试控制台中显示的错误消息:
Launching lib\main.dart on Chrome in debug mode...
../../AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.5.0/lib/palettes/tonal_palette.dart:110:42: Error: Inferred type argument 'double?' doesn't conform to the bound 'num' of the type variable 'T' on 'min'.
Try specifying type arguments explicitly so that they conform to the bounds.
final chroma = (tone >= 90.0) ? math.min(_chroma, 40.0) : _chroma;
^
../../AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.5.0/lib/palettes/tonal_palette.dart:112:30: Error: The argument type 'double?' can't be assigned to the parameter type 'double' because 'double?' is nullable and 'double' isn't.
tone, () => Hct.from(_hue, chroma, tone.toDouble()).toInt());
^
../../AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.5.0/lib/palettes/tonal_palette.dart:112:36: Error: The argument type 'double?' can't be assigned to the parameter type 'double' because 'double?' is nullable and 'double' isn't.
tone, () => Hct.from(_hue, chroma, tone.toDouble()).toInt());
^
../../AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.18.0/lib/src/canonicalized_map.dart:173:60: Error: Can't use an expression of type 'bool Function(K)?' as a function because it's potentially null.
Try calling using ?.call instead.
(key is K) && (_isValidKeyFn == null || _isValidKeyFn(key));
^
Failed to compile application.
Exited (1).
我希望 flutter 应用程序能够在 Chrome 和模拟器中运行。有没有人遇到过同样的问题或者之前解决过这个问题,请分享您的宝贵经验。我在这里等你来听。
我应该告诉大家我已经找到了解决方案。这只是一个安装问题(或者这是我最好的猜测)。我再次下载并重新安装后发现一切正常。事实上,我仍然不知道该错误行意味着什么,但现在我很高兴看到我的应用程序成功运行。