/C:/FlutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/fl_chart-0.50.5/lib/src/chart/pie_chart/pie_chart.dart:42:29:错误:方法“addPostFrameCallback”无法在“WidgetsBinding”上调用?因为它可能为空。
FAILURE:构建失败并出现异常。
地点: 脚本'C:\FlutterSdk lutter\packages lutter_tools\gradle lutter.gradle'行:1102
出了什么问题: 任务“:app:compileFlutterBuildDebug”执行失败。
处理'命令'C:\ FlutterSdk lutter in lutter.bat''以非零退出值1完成
尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。
33秒内构建失败 运行 Gradle 任务“assembleDebug”... 38.2s 异常:Gradle 任务 assembleDebug 失败,退出代码为 1
使用
flutter pub cache repair
命令
因为flutter将数据存储在自己的存储中,如果存储满了,就会抛出错误
lib 提供程序在迁移到 flutter 3 时发生了重大更改,但没有影响主要版本,您可以尝试在 pubspec.yml 中锁定版本或也迁移到 flutter 3...
还有另一个类似的错误,表明 dart 代码中有语法错误。完整的错误文本如下:
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/users/elmar/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
Running Gradle task 'assembleDebug'... 17.3s
Exception: Gradle task assembleDebug failed with exit code 1
您需要找到并更正语法错误,之后应用程序将运行而不会出现任何错误。
别忘了flutter pub get,我成功使用了这个方法