Flutter 2 构建项目:错误:没有为类“_LoadingIndicatorState”定义方法“SpinKitPouringHourglass”

Posted

技术标签:

【中文标题】Flutter 2 构建项目:错误:没有为类“_LoadingIndicatorState”定义方法“SpinKitPouringHourglass”【英文标题】:Flutter 2 build project: Error: The method 'SpinKitPouringHourglass' isn't defined for the class '_LoadingIndicatorState' 【发布时间】:2021-10-28 10:37:42 【问题描述】:

我正在尝试使用 android studio 启动我的项目,但在昨天运行时发生了错误。

AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_easyloading-3.0.0/lib/src/widgets/indicator.dart:166:22: Error: The method 'SpinKitPouringHourglass' isn't defined for the class '_LoadingIndicatorState'.
 - '_LoadingIndicatorState' is from 'package:flutter_easyloading/src/widgets/indicator.dart' ('/C:/Users/[MYUSER]/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_easyloading-3.0.0/lib/src/widgets/indicator.dart').
Try correcting the name to the name of an existing method, or defining a method named 'SpinKitPouringHourglass'.
        _indicator = SpinKitPouringHourglass(
                     ^^^^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\lib\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\lib\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 11s
Exception: Gradle task assembleDebug failed with exit code 1

我已经做了什么: 重新安装颤振SDK 重新安装 Android Studio 扑干净 删除构建文件夹 删除 pubseck.lock 扑吧酒吧 颤振酒吧升级 颤振酒吧过时了 扑医生:

C:\lib\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [version 10.0.19042.1165], locale fr-FR)
    • Flutter version 2.2.3 at C:\lib\flutter
    • Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\[MY_USER]\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Java\jdk1.8.0_291\bin\java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] VS Code (version 1.59.1)
    • VS Code at C:\Users\[MY_USER]\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 92.0.4515.159
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 92.0.902.84

! Doctor found issues in 1 category.
Process finished with exit code 0

我应该怎么做才能修复这个错误?

【问题讨论】:

尝试正确设置您的 java 路径,因为您的颤振医生给出了问题无法确定捆绑的 Java 版本。 已经设置好了:jdk1.8.0_291(在项目结构> SDKs > JDK home path) 你可以添加你的代码sn-p 不,我不能这是一个包含多个文件的大项目,我猜它不是来自文件,因为我检查了昨天的提交以确保我没有添加错误并且它是还是行不通。为了添加更多信息,当我尝试使用fluttericon.com(导入我的)向我的项目添加外部图标时发生了这种情况但是我删除了它们并从pubspec.yaml中删除了以前它在没有“无法确定捆绑的Java”的情况下工作版本。” (因为我无法修复它) 【参考方案1】:

我也有同样的问题。 flutter_easyloading 之前运行良好。 所以我找到“导入'包:flutter_spinkit/flutter_spinkit.dart';”在 flutter_easyloading 3.0.0 的 indicator.dart 中。 但是flutter_spinkit 已经发布了一个新版本5.1.0 并查看了ChangeLog,我发现日志“Renamed SpinKitPouringHourglass -> SpinKitPouringHourGlass for correctness”。

是的,flutter_easyloading 也必须修改以修复此错误。

【讨论】:

是的,flutter_easyloading 必须升级他的版本,所以问题还不能解决。所以从现在开始不要使用这个库。我们应该提议修复他的 git。您应该使用 pub.dev/packages/flutter_spinkit 而不是哑库。【参考方案2】:

您正在使用插件不存在的方法:flutter_easyloading。 Flutter 易加载是问题所在。

晚安

【讨论】:

嗯,这并不完全正确,但我刚刚删除了这个包

以上是关于Flutter 2 构建项目:错误:没有为类“_LoadingIndicatorState”定义方法“SpinKitPouringHourglass”的主要内容,如果未能解决你的问题,请参考以下文章

升级后在 nfc_in_flutter 上构建失败

错误:没有为类“BuildContext”定义方法“ancestorInheritedElementForWidgetOfExactType”

错误:没有为类 'Utf8' 定义 getter 'addressOf'

没有为类“BasicMessageChannel<dynamic>”定义方法“setMockMessageHandler”

没有为类“对象”定义运算符“[]”。扑

异常:flutter 项目上没有配置 Linux 桌面项目错误