Skip to content

Workaround to "cannot use "ref" after the widget was disposed" #3043

Answered by nicklbaert
Maldus512 asked this question in Q&A
Discussion options

You must be logged in to vote

@Maldus512 You can just do:

    onPressed: () async {
      final loginNotifier = ref.read(loginStateProvider.notifier);
      loginNotifier.loggingIn();
      await Future.delayed(const Duration(seconds: 1)); // Loggin in
      loginNotifier.loggedIn();
    },

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@Maldus512
Comment options

@nicklbaert
Comment options

Answer selected by Maldus512
@bhfish2020
Comment options

Comment options

You must be logged in to vote
1 reply
@rohinton-collins
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants