Open psimondk opened 4 years ago
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 !!!
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. 👍
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);