最新 Flutter 升级后 - 项目未构建

Posted

技术标签:

【中文标题】最新 Flutter 升级后 - 项目未构建【英文标题】:After Latest Flutter Upgrade - Project is not building 【发布时间】:2020-07-19 08:59:12 【问题描述】:

在构建时的所有项目中 - 面临此错误。颤振升级后,我遇到了这个错误。我已经尝试了所有升级和无效缓存以及所有 - 但是当我运行项目时发现了这个异常。

[+37924 ms] 
            Compiler message:
[   +6 ms] /D:/FlutterSDK/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/extended_image-0.7.2/lib/src/gesture/extended_image_slide_page_route.dart:333:9: Error: No named parameter with the name 'animation'.
[   +1 ms]         animation: animation,
[   +1 ms]         ^^^^^^^^^
[        ] /D:/FlutterSDK/flutter_windows_v1.5.4-hotfix.2-stable/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the arguments don't match.
[        ]   CupertinoFullscreenDialogTransition(
[   +1 ms]   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[+96166 ms] Compiler message:
[        ] /D:/FlutterSDK/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/extended_image-0.7.2/lib/src/gesture/extended_image_slide_page_route.dart:333:9: Error: No named parameter with the name 'animation'.
[        ]         animation: animation,
[        ]         ^^^^^^^^^
[        ] /D:/FlutterSDK/flutter_windows_v1.5.4-hotfix.2-stable/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the arguments don't match.
[        ]   CupertinoFullscreenDialogTransition(
[        ]   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[+13876 ms] Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
[   +1 ms] build failed.
[ +618 ms] FAILURE: Build failed with an exception.
[  +14 ms] * Where:
[        ] Script 'D:\FlutterSDK\flutter_windows_v1.5.4-hotfix.2-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 883
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildDebug'.
[        ] > Process 'command 'D:\FlutterSDK\flutter_windows_v1.5.4-hotfix.2-stable\flutter\bin\flutter.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 2m 28s

【问题讨论】:

animation 参数被github.com/flutter/flutter/pull/50180 拆分和重命名。因为显然没有使用 CupertinoFullscreenDialogTransition 的现有测试,所以该更改不会破坏任何测试,也不被视为破坏性更改。 @jamesdlin,好的,我期待相同的 - 但是如何在我不知道的拉取请求中找到此类信息。如何解决这个问题的一个问题?我应该怎么做? Error: No named parameter with the name 'animation'. 错误消息中,很明显CupertinoFullscreenDialogTransition 构造函数参数发生了变化。从那里我搜索了 flutter git 存储库以查找实现 CupertinoFullscreenDialogTransition 的位置,运行 git blame 以查看哪些提交修改了参数,并查看了其提交描述以找到引用的拉取请求。 你能告诉我们你在项目的 pubspec.yaml 文件中使用了哪些包/插件 我遇到了同样的问题,这修复了我的项目:See 【参考方案1】:

您需要检查构造函数上设置的参数名称,如错误中所述:Found this candidate, but the arguments don't match. CupertinoFullscreenDialogTransition

错误指向这个参数:Error: No named parameter with the name 'animation'.

检查 docs 的 CupertinoFullscreenDialogTransition,构造函数需要 primaryRouteAnimationsecondaryRouteAnimation

【讨论】:

以上是关于最新 Flutter 升级后 - 项目未构建的主要内容,如果未能解决你的问题,请参考以下文章

Flutter 项目升级报错处理

Flutter 2.10 升级指南

升级后无法在android studio上打开flutter项目

Flutter 构建失败 'UserAgent.h' 文件未找到

升级到最新的 SDK 版本 1.20.4 后运行/调试 Flutter 应用程序非常慢

Flutter:升级 Flutter 和 Channel 后无法再构建应用程序