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

9
尝试构建iOS应用时,出现以下输出:
在应用程序中删除对graphql_flutter的引用可消除这些错误。
我尝试了Flutter的每个通道,问题仍然存在。
../../../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.
              Response(data: cachedData),
                      ^
../../../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.
  const Response({
        ^^^^^^^^
../../../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.
  Response parseResponse(Map<String, dynamic> body) => Response(
                                                               ^
../../../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.
  const Response({
        ^^^^^^^^
../../../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.
    yield Response(
                  ^
../../../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.
  const Response({

来自 pubspec.yaml:

graphql_flutter: ^5.0.0
gql: ^0.13.0

来自 flutter doctor 命令(尚未安装 Android)

[✓] Flutter (Channel stable, 2.5.3, on macOS 11.5.2 20G95 darwin-x64, locale en-US)
    • Flutter version 2.5.3 at /Users/justin/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/justin/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.61.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.27.0

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • BB5BF139-9146-4AC0-8316-7D044BD283B8 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 95.0.4638.69

! Doctor found issues in 1 category.
1个回答

5
TLDR; 这个问题是由于 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"

如果您想更深入地了解此问题,请参考链接/gql_exec/lib/src/response.dart文件中的第27行,该参数已添加并声明为必需的。请查看以下提交:https://github.com/gql-dart/gql/commit/8699d2fcc285789ec6e891b034e98fd2b7750296#diff-99580a029d7aed82312588b8cda13419bc8f9c0e58ac97e1f7bcdad51fc39c10R27

4
我使用了一个依赖项覆盖,类似于以下内容:dependency_overrides: gql_exec: 0.3.0(注:该操作可能是针对某种软件或代码的,具体背景未知。) - tuan vu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接