为什么我无法使多个异步提供程序无效?

问题描述 投票:0回答:1
@Riverpod(keepAlive: true)
Future<HomePageData> homeData(HomeDataRef ref) async {
  final data = await Future.wait([
    ref.watch(walletBalanceProvider.future),
    ref.watch(marketTokensProvider.future),
    ref.watch(tokenChangesProvider.future),
    ref.watch(otcPairProvider.future),
  ]);

  return HomePageData(
    wallets: data[0] as List<Wallet>,
    marketTokens: data[1] as List<Token>,
    otcToken: data[2] as List<Token>,
    otcPair: data[3] as List<OtcPair>,
  );
}

我有这样的 homeDataProvider,

为什么当我调用 ref.invalidate(homeDataProvider) 时会返回错误,但一一使其失效却有效。

flutter riverpod
1个回答
0
投票

因为是keepAlive = true。也许其他的都不是单例。

© www.soinside.com 2019 - 2024. All rights reserved.