Flutter (graphql_flutter + gql):找到了这个候选者,但参数不匹配

Jus*_*dev 9 dart flutter

尝试构建应用程序(iOS)时,得到以下输出:

\n

删除对应用程序内的引用graphql_flutter可以消除这些错误。

\n

我已经尝试了 Flutter 的每个渠道,但问题仍然存在。

\n
../../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql-5.0.0/lib/src/core/query_manager.dart:427:23: Error: Required named parameter 'response' must be provided.\n              Response(data: cachedData),\n                      ^\n../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dart:23:9: Context: Found this candidate, but the arguments don't match.\n  const Response({\n        ^^^^^^^^\n../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_link-0.4.0/lib/src/response_parser.dart:10:64: Error: Required named parameter 'response' must be provided.\n  Response parseResponse(Map<String, dynamic> body) => Response(\n                                                               ^\n../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dart:23:9: Context: Found this candidate, but the arguments don't match.\n  const Response({\n        ^^^^^^^^\n../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_http_link-0.4.0/lib/src/link.dart:128:19: Error: Required named parameter 'response' must be provided.\n    yield Response(\n                  ^\n../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dart:23:9: Context: Found this candidate, but the arguments don't match.\n  const Response({\n
Run Code Online (Sandbox Code Playgroud)\n

来自 pubspec.yaml:

\n
graphql_flutter: ^5.0.0\ngql: ^0.13.0\n
Run Code Online (Sandbox Code Playgroud)\n

来自flutter doctor(尚未设置Android)

\n
[\xe2\x9c\x93] Flutter (Channel stable, 2.5.3, on macOS 11.5.2 20G95 darwin-x64, locale en-US)\n    \xe2\x80\xa2 Flutter version 2.5.3 at /Users/justin/flutter\n    \xe2\x80\xa2 Upstream repository https://github.com/flutter/flutter.git\n    \xe2\x80\xa2 Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700\n    \xe2\x80\xa2 Engine revision d3ea636dc5\n    \xe2\x80\xa2 Dart version 2.14.4\n\n[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0)\n    \xe2\x80\xa2 Android SDK at /Users/justin/Library/Android/sdk\n    \xe2\x9c\x97 cmdline-tools component is missing\n      Run `path/to/sdkmanager --install "cmdline-tools;latest"`\n      See https://developer.android.com/studio/command-line for more details.\n    \xe2\x9c\x97 Android license status unknown.\n      Run `flutter doctor --android-licenses` to accept the SDK licenses.\n      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.\n\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS\n    \xe2\x80\xa2 Xcode at /Applications/Xcode.app/Contents/Developer\n    \xe2\x80\xa2 Xcode 13.0, Build version 13A233\n    \xe2\x80\xa2 CocoaPods version 1.10.1\n\n[\xe2\x9c\x93] Chrome - develop for the web\n    \xe2\x80\xa2 Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome\n\n[\xe2\x9c\x93] Android Studio (version 4.0)\n    \xe2\x80\xa2 Android Studio at /Applications/Android Studio.app/Contents\n    \xe2\x80\xa2 Flutter plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/9212-flutter\n    \xe2\x80\xa2 Dart plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/6351-dart\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)\n\n[\xe2\x9c\x93] VS Code (version 1.61.0)\n    \xe2\x80\xa2 VS Code at /Applications/Visual Studio Code.app/Contents\n    \xe2\x80\xa2 Flutter extension version 3.27.0\n\n[\xe2\x9c\x93] Connected device (2 available)\n    \xe2\x80\xa2 iPhone 13 (mobile) \xe2\x80\xa2 BB5BF139-9146-4AC0-8316-7D044BD283B8 \xe2\x80\xa2 ios            \xe2\x80\xa2 com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)\n    \xe2\x80\xa2 Chrome (web)       \xe2\x80\xa2 chrome                               \xe2\x80\xa2 web-javascript \xe2\x80\xa2 Google Chrome 95.0.4638.69\n\n! Doctor found issues in 1 category.\n
Run Code Online (Sandbox Code Playgroud)\n

dak*_*ine 5

太长了;此问题是由于 gql_exec 包含有关依赖库尚未实现的参数的近期重大更改。

要解决此问题,请使用以下方法之一:

  • 在 pubspec.lock 文件中使用下面的代码片段,并且在库之间解决此重大更改之前不要运行升级。(最快的解决方案)
  • 使用固定版本,直到依赖库支持此功能。(更好但更慢的解决方案)
  • gql_exec 使用 PATCH 号更新其代码以确保这不是重大更改(请参阅:SEMVER)。(最好的解决方案,但可能需要一段时间)

参考我们的 pubspec.lock 文件,我们使用以下版本构建

gql:
    dependency: "direct main"
    description:
      name: gql
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.13.1-alpha+1633799193898"
  gql_build:
    dependency: "direct dev"
    description:
      name: gql_build
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.0-alpha+1633799193977"
  gql_code_builder:
    dependency: transitive
    description:
      name: gql_code_builder
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.0-alpha+1633799193964"
  gql_dedupe_link:
    dependency: transitive
    description:
      name: gql_dedupe_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.0"
  gql_error_link:
    dependency: transitive
    description:
      name: gql_error_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.0"
  gql_exec:
    dependency: transitive
    description:
      name: gql_exec
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.1-alpha+1633799193908"
  gql_http_link:
    dependency: transitive
    description:
      name: gql_http_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.0"
  gql_link:
    dependency: transitive
    description:
      name: gql_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.0"
  gql_transform_link:
    dependency: transitive
    description:
      name: gql_transform_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.0"
  gradient_widgets:
    dependency: "direct main"
    description:
      name: gradient_widgets
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.6.0"
  graphql:
    dependency: transitive
    description:
      name: graphql
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.0.0"
  graphql_flutter:
    dependency: "direct main"
    description:
      name: graphql_flutter
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.0.0"
Run Code Online (Sandbox Code Playgroud)

如果您想更深入地了解这一点,请参阅以下提交中的文件 links/gql_exec/lib/src/response.dart 第 27 行,其中根据需要添加并声明了新参数。 https://github.com/gql-dart/gql/commit/8699d2fcc285789ec6e891b034e98fd2b7750296#diff-99580a029d7aed82312588b8cda13419bc8f9c0e58ac97e1f7bcdad51fc39c10R27

  • 我使用了如下所示的依赖项覆盖:`dependency_overrides: gql_exec: 0.3.0` (4认同)