Skip to content

The getter 'future' isn't defined - n00b alert #3444

Answered by charlescyt
amireldor asked this question in Q&A
Discussion options

You must be logged in to vote

That's because authProvider is not referring to the actual generated FutureProvider. It is referring to the function

@riverpod
Future<String> authProvider(AuthProviderRef ref) async {
  await Future.delayed(const Duration(seconds: 3));
  return 'hello';
}

Change the code to await ref.watch(authProviderProvider.future); and it will work.
But this is rather confusing having a ProviderProvider so generally you wouldn't suffix your provider with provider.

@riverpod
Future<String> auth(AuthRef ref) async {
  await Future.delayed(const Duration(seconds: 3));
  return 'hello';
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@amireldor
Comment options

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