Flutter user registration storing data

I'm new to flutter. I need some help with Registering users with my app. I'm using Firebase authentication just to get the email and I need to save the details of the users in a database. I'm trying with cloud firestore, but I'm feeling like its not the best ideal option. And when login I want verify if the user is registered or not

Upvotes: 1

Views: 935

Answers (1)

Neha Bhardwaj
Neha Bhardwaj

Reputation: 1393

you can use this code for registration user in Cloud Firestore

    final FirebaseAuth _auth = FirebaseAuth.instance;

     _auth
                  .createUserWithEmailAndPassword(
                      email: _myEmail, password: _myPassword)
                  .catchError((e) {
                showDialog(
                    context: context,
                    builder: (context) {
                      return CupertinoAlertDialog(
                        title: Text('Error Occured'),
                        content: Text(e.toString()),
                        actions: <Widget>[
                          CupertinoButton(
                              child: Text('Ok'),
                              onPressed: () => Navigator.of(context).pop())
                        ],
                      );
                    });   



         FirebaseAuth.instance
                      .signInWithEmailAndPassword(email: _myEmail, password: _myPassword)
                      .catchError((e) {
                    showDialog(
                        context: context,
                        builder: (context) {
                          return CupertinoAlertDialog(
                            title: Text('Error Occured'),
                            content: Text(e.toString()),
                            actions: <Widget>[
                              CupertinoButton(
                                  child: Text('Ok'),
                                  onPressed: () => Navigator.of(context).pop())
                            ],
                          );
                        });

Upvotes: 1

Related Questions