You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to get the $id of the current user in initState, since I can't use context there?
Here is an example:
@overridevoidinitState() {
super.initState();
boatsStream =DB.boat.streamBoats(uid); // Initialize the stream
}
I somehow need to get the users id here. But it's not only initState functions where I need to get the $id without context, for example in the toMap function of some of my models I also need it.
The text was updated successfully, but these errors were encountered:
You need to refactor you code to use it other way. It works with context because we do need context to access the state data. As we are using the inherited widget, we need context to access the data. You can easily refactor your code to pass context.
For initState you could move your logic to didChangeDependencies (https://api.flutter.dev/flutter/widgets/State/didChangeDependencies.html)
Is there a way to get the
$id
of the current user ininitState
, since I can't usecontext
there?Here is an example:
I somehow need to get the users id here. But it's not only
initState
functions where I need to get the$id
withoutcontext
, for example in thetoMap
function of some of my models I also need it.The text was updated successfully, but these errors were encountered: