Once you have called dispose() on a NotesProvider, it can no longer be used. #664
Unanswered
akshayindia
asked this question in
Q&A
Replies: 1 comment
-
Chances are that your provider was unmounted, so the object exposed was dispose, and therefore unsable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
I am facing the issue in the provider package, I have called 3 providers inside didchangedependency and all is showing the same error, once you have called dipose. it can no longer be used.
To Reproduce
I'm using Dashboard as the home screen where I am call didchangedependcy -
@OverRide
void didChangeDependencies() {
if (_isInit) {
setState(() {
_isLoading = true;
});
}
@OverRide
void dispose() {
socket!.dispose();
socket!.disconnect();
socket!.off(
"message",
);
super.dispose();
}
This is the main.dart where I called Multiprovider
@OverRide
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: Auth()),
ChangeNotifierProxyProvider<Auth, ProjectProvider>(
create: (ctx) => ProjectProvider(Auth().token, []),
update: (ctx, auth, previousProject) => ProjectProvider(
auth.token,
previousProject == null ? [] : previousProject.items,
),
),
ChangeNotifierProxyProvider2<Auth, ProjectProvider, SocketProvider>(
create: (ctx) => SocketProvider(Auth().userId, []),
update: (ctx, auth, previousNotes, prov2) =>
SocketProvider(auth.userId, previousNotes.items),
),
ChangeNotifierProxyProvider<Auth, ScriptProvider>(
create: (ctx) => ScriptProvider(Auth().token, [], [], []),
update: (ctx, auth, previousScript) => ScriptProvider(
auth.token,
previousScript == null ? [] : previousScript.getScript,
previousScript!.getFilterScript,
previousScript.getRecentScript,
),
),
ChangeNotifierProxyProvider<Auth, TeamProvider>(
create: (ctx) => TeamProvider(
Auth().token,
Auth().userId,
Auth().name,
Auth().email,
[],
),
update: (ctx, auth, previousScript) => TeamProvider(
auth.token,
auth.userId,
auth.name,
auth.email,
previousScript == null ? [] : previousScript.getTeamInProject,
),
),
ChangeNotifierProxyProvider2<Auth, TeamProvider, MessageProvider>(
create: (context) =>
MessageProvider(Auth().token, Auth().userId, []),
update: (_, prov1, prov2, prov3) => MessageProvider(prov1.token,
prov1.userId, prov3 == null ? [] : prov3.allChatUsersMessages)
..allChatUsersOfTeams((prov2.getAllTeamMember))),
ChangeNotifierProxyProvider<Auth, NotesProvider>(
create: (ctx) => NotesProvider(Auth().token, []),
update: (ctx, auth, previousNotes) => NotesProvider(
auth.token,
previousNotes == null ? [] : previousNotes.getNotes,
),
),
ChangeNotifierProxyProvider<Auth, PaymentProvider>(
create: (ctx) => PaymentProvider(
Auth().token,
Auth().package,
Auth().startdate,
Auth().endDate,
[],
0.0,
0.0,
0.0,
0.0,
0.0,
'',
''),
update: (ctx, auth, previousProject) => PaymentProvider(
auth.token,
auth.package,
previousProject!.startDate,
previousProject.endDate,
previousProject.listOfPacakge,
previousProject.defaultprice,
previousProject.finalprice,
previousProject.coupondiscount,
previousProject.price,
previousProject.cureentPackage,
previousProject.couponName,
previousProject.packageName)),
],
child: Consumer(
builder: (ctx, auth, _) => MaterialApp(
debugShowCheckedModeBanner: false,
theme: MyThemes.lightTheme,
themeMode: ThemeMode.system,
// darkTheme: MyThemes.darkTheme,
// darkTheme: MyThemes.darkTheme,
home: auth.isAuth
? Dashboard()
: FutureBuilder(
future: auth.tryAutoLogin(),
builder: (ctx, authResultSnapshot) =>
authResultSnapshot.connectionState ==
ConnectionState.waiting
? SplashScreen()
: AuthScreen(),
),
Expected behavior
A clear and concise description of what you expected to happen.
Beta Was this translation helpful? Give feedback.
All reactions