我无法调试颤振项目
这是错误
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/country_pickers-1.3.0/lib/utils/my_alert_dialog.dart:139:36: Error: Method not found: 'ButtonTheme.bar'.
children.add(new ButtonTheme.bar(
^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:srcflutterpackagesflutter_toolsgradleflutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:srcflutterbinflutter.bat'' 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 18s
Exception: Gradle task assembleDebug failed with exit code 1
错误:
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/country_pickers-1.3.0/lib/utils/my_alert_dialog.dart:139:36: Error: Method not found: 'ButtonTheme.bar'.
children.add(new ButtonTheme.bar(
正在告诉您Error: Method not found: 'ButtonTheme.bar'
发生在程序包country_pickers-1.3.0
中。仅搜索错误消息会发现错误:未找到方法:';按钮主题。bar';这告诉您ButtonTheme.bar
已被弃用,现在显然不再支持它。
转到country_pickers
软件包页面,找到Changelog并搜索ButtonTheme.bar
,我们看到:
[2.0.0] - 03/13/2021
Null-safety is added
Fix issue #40 (Country Code Not available for "Lao People's Democratic Republic") by @Tan-JamickoJohn
Fix issue #53 and #59 (Deprecated ButtonTheme.bar is removed) by @phamnhuvu-dev
Fix issue #45 (Search doesn't show all results) by @shadyshrif
Thanks @phamnhuvu-dev, @shadyshrif, @Tan-JamickoJohn
因此,包所有者在版本2.0.0
中修复了该问题。
因此,您必须a(停止使用此软件包,b(升级到新的软件包版本,或者c(使用仍然支持ButtoneTheme.bar
的Flutter版本。b(的问题是,新版本支持零安全,这将要求您自己采用零安全-请参阅此链接。c(的问题是,你将被束缚在旧版本的Flutter上,这不是一个好主意。
这是一个非常常见的错误,很容易修复。
- 步骤1:您需要打开电脑的Netowrk
- 步骤2:然后还要确保您的代码没有故障
- 步骤3(可选(:此外,如果您正在使用Git,则签入Flutter有时会自动添加一些更新,因此如果是不必要地将其删除或进行丢弃更改
如果你没有Git,不要担心。
- 第4步:剪切VS代码并从Scratch开始
-
步骤5:另外,使用
flutter clean
命令,然后刷新pubspec.yaml
-
步骤6:
flutter upgrade
it - 第7步:尽情享受,#noErrors