Skip to content
New issue

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

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

Already on GitHub? # to your account

No user creation #7

Open
psimondk opened this issue Sep 11, 2020 · 2 comments
Open

No user creation #7

psimondk opened this issue Sep 11, 2020 · 2 comments

Comments

@psimondk
Copy link

psimondk commented Sep 11, 2020

Updated:
Used the instructions and inserted the following in register_screen in order to patch the app so that user creation actually lead to a user record in the database. Alas it throws the dreaded "Error: Could not find the correct provider ..." - So what is the deal with register_screen?

FirestoreDatabase firestoreDatabase = Provider.of<FirestoreDatabase>(context);

@psimondk
Copy link
Author

Patched:

if (userModel == null) { _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text(AppLocalizations.of(context) .translate("loginTxtErrorSignIn")), )); } else { // Patched to allow user creation in DB // Terrible hack - but life is too short for providers and other gluecode final FirestoreDatabase firestoreDatabase = FirestoreDatabase(uid: userModel.uid); firestoreDatabase.setUser(userModel); } }

And in firetore_database.dart:

//Method to create/update userModel Future<void> setUser(UserModel user) async => await _firestoreService.setData( path: FirestorePath.user(uid), data: user.toMap(), );

And in user_model.dart:
`class UserModel {
String uid;
String email;
String displayName;
String phoneNumber;
String photoUrl;

UserModel(
{this.uid,
this.email,
this.displayName,
this.phoneNumber,
this.photoUrl});

Map<String, dynamic> toMap() {
return {'uid': uid, 'email': email};
}
}`

Apart from this - great template !!!

@KenAragorn
Copy link
Owner

Hi @psimondk ,

Thanks for the info. Been cought up with project work. Yes, we need to capture the user into Firebase. Thanks for the sharing of tips - yup, adding the UserModel and the services will resolve the issue. 👍

timemapmaker added a commit to timemapmaker/create_flutter_provider_app that referenced this issue Dec 30, 2020
run using flutter run --flavor dev -t lib/main.dart
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants