static void signUpUser(
BuildContext context, String name, String email, String password) async {
try {
AuthResult authResult = await _auth.createUserWithEmailAndPassword(
email: email,
password: password
);
FirebaseUser signedInUser = authResult.user;
if (signedInUser != null) {
_firestore.collection('/users').document(signedInUser.uid).setData({
'name': name,
'email': email,
'profileImageUrl': '',
});
//sign up page
final _formKey = GlobalKey<FormState>();
String _name, _email, _password;
_submit() {
if(_formKey.currentState.validate()){
_formKey.currentState.save();
AuthService.signUpUser(context, _name, _email, _password);
}
}
//my main.dart
Widget _getScreenId() {
return StreamBuilder<FirebaseUser>(
stream: FirebaseAuth.instance.onAuthStateChanged,
builder: (BuildContext context, snapshot) {
if (!snapshot.hasData) {
Provider.of<UserData>(context).currentUserId = snapshot.data.uid;
return LoginScreen();
} else {
return HomeScreen();
}
},
);
}
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/8fcd8fef-e7b6-49a4-b6fc-4ff4d6cae88a%40googlegroups.com.
On Mar 12, 2020, at 7:34 AM, Error Place <reza7....@gmail.com> wrote:
Ive nog created the Update function, so my users can update their informationClass DatabaseService {static void updateUserData(User user){UsersRef.document(user.id).updateData({Name .......Profile image ........Biografy.......});}But I still don’t know how to set the isAdmin = true;I want the user to be able to choose admin! Or regular user in the signup page and then based on the chosen role get directed to different screens!Thanks in advance 🙏tors 12 mars 2020 kl. 00:02 skrev Error Place <reza7....@gmail.com>:Thank you. I‘be already gone through the docs , but I guess I missed that. I will give it a try🙏🙏ons 11 mars 2020 kl. 23:55 skrev tomohiro suzuki <tomotom...@gmail.com>:Good. Then you need to know how to save a document per user. Very similar to
_firestore.collection('/users').document(signedInUser.uid).setData({ 'name': name, 'email': email, 'profileImageUrl': '', })
But with “updateData” method this time. For difference between setData and updateData:Thank you for your response.My app runs on both iOS and Android, and it also signs up user. But it doesn’t assign roles to user though I don’t know how to write the code that makes it happen! I can set user roles manually in the firebase console but don’t know how to figure out the navigation either.Best regardsons 11 mars 2020 kl. 22:08 skrev Suzuki Tomohiro <tomotom...@gmail.com>:Does your app run in yours device (iOS/Android/Web)?Does your app let your user sign-in?Does your app assign a role to a user?Does your users see different pages by the role?On Wed, Mar 11, 2020 at 4:46 PM Error Place <reza7....@gmail.com> wrote:What I’m would like to achieve is that users with admin role get special UI and access to every pageWhile regular user only can see some pages.Best regards