Flutter:没有为“RetryOptions”类定义吸气剂“Pestawait”

Posted

技术标签:

【中文标题】Flutter:没有为“RetryOptions”类定义吸气剂“Pestawait”【英文标题】:Flutter : The getter 'Pestawait' isn't defined for the class 'RetryOptions' 【发布时间】:2021-02-27 20:44:20 【问题描述】:

我尝试实现一个应用程序。我运行了几次,没有错误。但是没有任何原因,一天后我尝试运行我的应用程序,我得到了以下错误,我试图找到 id 的解决方案但我没有找到任何东西。

那么有人可以告诉我如何解决它吗?


Launching lib\main.dart on sdk gphone x86 in debug mode...
 lib\main.dart
../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/retry-3.0.1/lib/retry.dart:131:16: Error: Expected ';' after this.
        return Pestawait fn();
               ^^^^^^^^^
../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/retry-3.0.1/lib/retry.dart:131:16: Error: The getter 'Pestawait' isn't defined for the class 'RetryOptions'.
 - 'RetryOptions' is from 'package:retry/retry.dart' ('../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/retry-3.0.1/lib/retry.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Pestawait'.
        return Pestawait fn();
               ^^^^^^^^^
../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.4.0/lib/flutter_datetime_picker.dart:215:48: Error: No named parameter with the name 'shadowThemeOnly'.
    ThemeData inheritTheme = Theme.of(context, shadowThemeOnly: true);
                                               ^^^^^^^^^^^^^^^
../../../flutter/flutter/packages/flutter/lib/src/material/theme.dart:119:20: Context: Found this candidate, but the arguments don't match.
  static ThemeData of(BuildContext context) 
                   ^^


FAILURE: Build failed with an exception.

* Where:
Script 'D:\mohy\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 900

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\mohy\flutter\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 9m 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

【问题讨论】:

【参考方案1】:

看来你的图书馆坏了。您可以删除该文件夹并再次安装该软件包。或者为了快速修复,您可以在相关文件中更改该部分,如here。


 Future<T> retry<T>(
    FutureOr<T> Function() fn, 
    FutureOr<bool> Function(Exception)? retryIf,
    FutureOr<void> Function(Exception)? onRetry,
  ) async 
    var attempt = 0;
    // ignore: literal_only_boolean_expressions
    while (true) 
      attempt++; // first invocation is the first attempt
      try 
        return await fn(); // Here is broken!
       on Exception catch (e) 
        if (attempt >= maxAttempts ||
            (retryIf != null && !(await retryIf(e)))) 
          rethrow;
        
        if (onRetry != null) 
          await onRetry(e);
        
      

      // Sleep for a delay
      await Future.delayed(delay(attempt));
    
  


【讨论】:

以上是关于Flutter:没有为“RetryOptions”类定义吸气剂“Pestawait”的主要内容,如果未能解决你的问题,请参考以下文章

Flutter:没有为“Object”类型定义运算符“[]”。尝试定义运算符'[]'

Flutter - 错误:没有为“对象”类型定义吸气剂“文档”

Flutter:没有为“Box”类型定义方法“listenable”(使用 Hive)

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

Dart / Flutter - 有没有像 javascript 一样为 HTML 块获取 innerText? [复制]

Flutter markdown 包依赖项没有为我正确安装