【问题标题】:Flutter: Found this candidate, but the arguments don't matchFlutter:找到了这个候选人,但参数不匹配
【发布时间】:2020-07-15 16:29:20
【问题描述】:

我正在开发一个颤振应用程序,项目运行良好,但突然项目没有运行,它给了我一个错误。

这是我尝试运行应用程序时收到的错误代码

Compiler message:
/C:/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,
        ^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the arguments don't match.
  CupertinoFullscreenDialogTransition({
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.15.0/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
  PictureStream();
  ^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.15.0/lib/src/picture_stream.dart:192:16: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
abstract class PictureStreamCompleter extends Diagnosticable {
               ^
/C:/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,                                           
        ^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the arguments don't match.
  CupertinoFullscreenDialogTransition({
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.15.0/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
  PictureStream();
  ^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.15.0/lib/src/picture_stream.dart:192:16: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
abstract class PictureStreamCompleter extends Diagnosticable {
               ^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.                                                           

FAILURE: Build failed with an exception.
                                                                        

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\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.

BUILD FAILED in 43s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        44.9s
Exception: Gradle task assembleDebug failed with exit code 1

【问题讨论】:

  • 嗨 Moaaz,请尝试包含正在尝试做的简短描述、导致此错误的原因以及您为尝试修复此错误所做的工作。如果我们只看到一堆错误日志,没有人知道如何为您提供帮助。请阅读本指南:How to ask.
  • 你找到解决办法了吗?

标签: flutter dart compiler-errors flutter-dependencies run-app


【解决方案1】:

尝试添加您的 pubsepc.yaml flutter_svg: ^0.17.3+1。 对我有用

【讨论】:

  • 当我只包含这个 flutter_svg: ^0.17.3+1 文件时,最初确实有效。但这对我也有用,在运行 "flutter clean" 命令之后,然后将 flutter_svg: ^0.17.3+1 包含在pubsepc.yaml 后跟 "flutter pub get"(我的 VSCode IDE 中的颤振扩展不会自动执行)命令。跨度>
【解决方案2】:

删除版本号并更新 pubsepc.yaml 文件 要么 包的更新版本

【讨论】:

    【解决方案3】:

    动画参数被github.com/flutter/flutter/pull/50180拆分和重命名。因为显然没有使用 CupertinoFullscreenDialogTransition 的现有测试,所以该更改不会破坏任何测试,也不会被视为破坏性更改。

    我正在研究如何在现有结构中解决此问题,我会尽快通知您。同时只是更新你 - 它被团队重命名为公共 API。

    【讨论】:

    • 来自错误:没有名为“动画”的命名参数。错误消息,很明显 CupertinoFullscreenDialogTransition 构造函数参数已更改。从那里我搜索了 Flutter git 存储库以了解 CupertinoFullscreenDialogTransition 的实现位置,运行 git blame 以查看哪些提交修改了参数,并查看了其提交描述以找到引用的拉取请求。
    【解决方案4】:

    这个解决方案对我有用:

    https://github.com/inspireui/support/issues/2740#issuecomment-614582990

    我只是将频道切换到稳定版

    【讨论】:

    • 谢谢。我在运行flutter run --flavor prod 时遇到了类似的错误../.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.,我通过使用git clone https://github.com/flutter/flutter.git -b stable(而不是'master' 或'beta' 分支)安装Flutter 的'stable' 分支然后使用@ 执行它来解决这个问题987654325@
    【解决方案5】:

    我使用的是火焰依赖火焰:^0.17.3 我改成现在的火焰:^0.20.1 如果你正在使用火焰依赖,试试吧!

    【讨论】:

      【解决方案6】:

      将flutter_svg升级到最新版本并检查是否有其他依赖它的包不会给你任何错误。如果您收到有关 flutter_svg 的另一个错误,则只需评论该包和任何其他依赖于 flutter_svg 的包并再次检查

      【讨论】:

        【解决方案7】:

        如果由于依赖另一个包而升级包后仍然出现错误 - 只需使用相同版本的flutter_svg-0.15.0,因为许多依赖包仍未升级。

        转到你的flutter SDK文件夹-flutter.pub-cache\hosted\pub.dartlang.org\flutter_svg-0.15.0\lib\src

        打开picture_stream.dart 文件并进行以下更改。

        1. abstract class PictureStreamCompleter extends Diagnosticable => abstract class PictureStreamCompleter with DiagnosticableMixin

        2. class PictureStream extends Diagnosticable => class PictureStream with DiagnosticableMixin

        以上解决方案是基于flutter的这个pull request。

        为了同时支持稳定版和测试版,我建议应该这样做

        Class PictureStream with DiagnosticableMixin { ... } 直到 DiagnosticableMixin 被正式弃用。

        flutter/flutter#50498

        然后运行 ​​pub get 并运行项目。

        上述解决方案仅在以下情况下有效 - flutter_svg 不在您当前的项目中,而是在您的 .pub_cache 中 - 所以和您在当前项目中使用的依赖包 - 所以这将是解决方案 直到 DiagnosticableMixin 被正式弃用。

        【讨论】:

          【解决方案8】:

          如果您使用extended_image,您可能需要更新它,这对我有用:

          extended_image: ^0.7.3-dev
          

          Source

          【讨论】:

            【解决方案9】:

            试试这个:

            首先运行一个,

            1. “flutter clean” 命令, 然后包括,
            2. pubsepc.yaml 中的 flutter_svg: ^0.17.3+1 后跟一个,
            3. “flutter pub get” 命令。 然后运行您的代码,看看您是否仍然会收到此错误。这对我有用

            【讨论】:

            • 因为 fstore 依赖于 koukicons 2.0.2 又依赖于flutter_svg ^0.15.0,所以需要flutter_svg ^0.15.0。所以,由于fstore依赖flutter_svg ^0.17.3+1,版本求解失败。
            【解决方案10】:

            使用最新版本的包 (flutter_svg: ^0.18.0)

            对我有用

            【讨论】:

              【解决方案11】:

              首先我运行了这个命令

              flutter clean
              

              然后我将最新版本添加到我的 pubspec.yaml 文件中

              flutter_svg: ^0.18.0
              

              然后我运行以下命令

              flutter pub get
              

              那我跑成功了

              【讨论】:

                【解决方案12】:
                1. 在 pubsepc.yaml 中将 flutter_svg 升级到最新版本
                2. 然后在终端“flutter pub get”中运行以下命令

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 2021-06-12
                  • 1970-01-01
                  • 1970-01-01
                  • 2021-05-22
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  相关资源
                  最近更新 更多