gpt4 book ai didi

flutter - A Provider 被处理后被使用 - Multiprovider

转载 作者:行者123 更新时间:2023-12-03 02:43:15 25 4
gpt4 key购买 nike

在我添加了 ProfileLogic 的依赖之后至 LocationLogic应用程序启动时出现以下错误:

I/flutter (14674): A LocationLogic was used after being disposed.

I/flutter (14674): Once you have called dispose() on a LocationLogic, it can no longer be used.


这些是我的提供者:
      providers: [
ChangeNotifierProvider(builder: (_) => ConnectivityLogic()),
ChangeNotifierProxyProvider<ConnectivityLogic, ProfileLogic>(
builder: (context, connectivity, previousMessages) =>
ProfileLogic(connectivity.isOnline),
initialBuilder: (BuildContext context) => ProfileLogic(false),
),
ChangeNotifierProxyProvider<ProfileLogic, LocationLogic>(
builder: (context, profileLogic, previousMessages) =>
LocationLogic(profileLogic.profile),
initialBuilder: (BuildContext context) => LocationLogic(null),
),
ChangeNotifierProvider(builder: (_) => SignUpModel()),
ChangeNotifierProxyProvider<ConnectivityLogic, WorkLogic>(
builder: (context, connectivity, previousMessages) =>
WorkLogic(connectivity.isOnline),
initialBuilder: (BuildContext context) => WorkLogic(false),
),
ChangeNotifierProvider(builder: (_) => OrderLogic()),
]
奇怪的是,一切正常,即使有那个错误。

最佳答案

我认为你处理了一个包含这些提供者的小部件。尝试将所需的提供程序在树中移到更高的位置。所以如果你有:

        MaterialApp(
home: MultiProvider(
providers: [...],
child: child,
)
)
做类似的事情:
        MultiProvider(
providers: [...],
child: MaterialApp(
home: child,
)
)
如果这无济于事,您需要提供更多背景信息。例如。什么是小部件树。

关于flutter - A Provider 被处理后被使用 - Multiprovider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58896629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com