【问题标题】:Error: Too many positional arguments: 1 allowed, but 2 found. Try removing the extra positional arguments. super.addToScene(builder, layerOffset);错误:位置参数太多:允许 1 个,但找到了 2 个。尝试删除额外的位置参数。 super.addToScene(builder, layerOffset);
【发布时间】:2021-12-18 09:52:56
【问题描述】:

从 2.5 升级到 Flutter 2.8 后出现此错误,运行 flutter clean 但无法解决
../../flutter/.pub-cache/hosted/pub.dartlang.org/visibility_detector-0.2.0/lib/src/visibility_detector_layer.dart:276:21:错误:位置参数太多:允许1个,但是2 找到。 尝试删除额外的位置参数。 super.addToScene(builder, layerOffset); 扑医生

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.5.2 20G95 darwin-arm, locale en-KE)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 13.2)
✗ CocoaPods installed but not working.
    You appear to have CocoaPods installed but it is not working.
    This can happen if the version of Ruby that CocoaPods was installed with is   different from the one
    being used to invoke it.
    This can usually be fixed by re-installing CocoaPods.
  To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for
  instructions.
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google
Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Community Edition (version 2021.3)
[✓] VS Code (version 1.63.0)
 [✓] Connected device (1 available)
! Doctor found issues in 3 categories.

颤振版本

Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (2 days ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

代码在 2.5 上运行良好,直到升级

【问题讨论】:

  • 试用0.2.2版
  • 它也不适用于 visibility_detector-0.2.2

标签: flutter dart


【解决方案1】:

使用 visibility_detector 0.2.2。

【讨论】:

  • 将 visibility_detector 添加到您的 pubspec.yaml:visibility_detector 0.2.2。然后运行,它应该可以工作
  • 如果您使用的是 focus_detector,请将其升级到 2.0.1
【解决方案2】:
  1. 从 Flutter 安装路径打开以下文件。 flutter/.pub-cache/hosted/pub.dartlang.org/firexcode-1.0.8/lib/src/Modules/visibility_detector/visibility_detector_layer.dart

  2. 在第 276 行更新代码部分

来自

super.addToScene(builder, layerOffset);

super.addToScene(builder/*, layerOffset*/);
  1. 然后再次构建,它会工作。

【讨论】:

  • 你正在编辑 pub,这是一种临时解决方案,不推荐使用,它会在 flutter clean 上消失
  • 是的,我同意。希望它会在下一个颤振版本中得到修复。
猜你喜欢
  • 2021-01-12
  • 2021-10-16
  • 2021-11-10
  • 1970-01-01
  • 1970-01-01
  • 2020-06-15
  • 2021-09-21
  • 2022-07-20
  • 2022-01-19
相关资源
最近更新 更多