Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Access Firestore from Register while trying to register. #12

Closed
fhidal01 opened this issue May 29, 2021 · 0 comments
Closed

Comments

@fhidal01
Copy link

I am very new to flutter so Im still trying to wrap my head around how this project is structured and understand how data is flowing. But what I am trying to do is when a new user try's to register an account I want to first query Firestore to see if they have been invited before allowing registration to happen.

My first guess was to simply use Provider of to gain access to the FirestoreDatabase service inside the register_screen.dart file like so:

Widget _buildForm(BuildContext context) { final authProvider = Provider.of<AuthProvider>(context); final firestoreDatabase = Provider.of<FirestoreDatabase>(context, listen: false);

but got and error saying:
Could not find the correct Provider<FirestoreDatabase>

I believe this has something to do with the widget tree hierarchy and how the FirestoreDatabase is not above the register page but im not sure. Any suggestions?

Also a related question I have is FirestoreDatabase does not extend ChangeNotifier so how are we even able to use something like

Provider.of<FirestoreDatabase>(context, listen: false);

when FirestoreDatabase is not a real provider, it doesn't notify any changes? Can any regular class be pulled in with Provider.of ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant