更新pubspec.yaml文件后获取错误 例如我正在尝试添加 fluttertoast:^ 7.1.1 pubspec.yaml中的相关性,并导入“ package:fluttertoast / fluttertoast.dart”; 在main.dart中
当我运行此项目时出现错误:
Running Xcode build...
Xcode build done. 8.4s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
lib/main.dart:29:9: Error: No named parameter with the name 'visualDensity'.
visualDensity: VisualDensity.adaptivePlatformDensity,
^^^^^^^^^^^^^
../../../flutter/packages/flutter/lib/src/material/theme_data.dart:201:11: Context: Found this candidate, but the arguments don't
match.
factory ThemeData({
^
../../../flutter/packages/flutter/lib/src/widgets/media_query.dart:126:32: Error: The getter 'physicalDepth' isn't defined for the
class 'Window'.
- 'Window' is from 'dart:ui'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'physicalDepth'.
physicalDepth = window.physicalDepth,
^^^^^^^^^^^^^
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 8.
任何人都有逐步解决方案。
谢谢。
答案 0 :(得分:0)
似乎ThemeData类未正确加载到内存中。试试这个解决方案:
flutter clean
flutter pub cache repair
如果上述方法无效,请尝试将以下内容添加到您的MaterialApp中:
ThemeData(
primarySwatch: appThemeColor,
visualDensity: VisualDensity.adaptivePlatformDensity,
)