首页 > 解决方案 > Error: The method 'ignore' isn't defined for the class 'Future' in flutter build

问题描述

Today when I compile my flutter project, the OS is macOS Big Sur, shows error like this:

../../../.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/riverpod-1.0.0-dev.10/lib/src/async_value_converters.dart:223:39: Error: The method 'ignore' isn't defined for the class 'Future<State>'.
 - 'Future' is from 'dart:async'.
Try correcting the name to the name of an existing method, or defining a method named 'ignore'.
            loadingCompleter!.future..ignore(),
                                      ^^^^^^

I am using the riverpod dependencies like this:

hooks_riverpod: ^1.0.0-dev.6

This problem was the first time to occurred. what should I do to fix this problem? This is the flutter environment info:

$ ~/apps/flutter/bin/flutter doctor                                                                                                         ‹ruby-2.7.2›
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2.3 20D91 darwin-x64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
    ✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.60.2)
[✓] Connected device (3 available)
    ! Error: xiaoqiang 的 iPhone is not connected. Xcode will continue when xiaoqiang 的 iPhone is connected. (code -13)

! Doctor found issues in 1 category.
(base)

标签: flutter

解决方案


我强制项目使用较低版本的 Riverpod 修复此问题:

riverpod: 1.0.0-dev.6

推荐阅读