flutter firebase login and registration code example

Example 1: how to sign out user in flutter with firebase authentication

final FirebaseAuth _auth = FirebaseAuth.instance;

Future<void> _signOut() async {
    await _auth.signOut();
  }

Example 2: registration in flutter

onPressed: () async {
                  setState(() {
                    spooner = true;
                  });
                  try {
                    final newUser = await _auth.createUserWithEmailAndPassword(
                        email: email, password: password);
                    if (newUser != null) {
                      Navigator.pushNamed(context, ChatScreen.id);
                    }
                    setState(() {
                      spooner = false;
                    });
                  } catch (e) {
                    print(e);
                  }

Example 3: how to sign out user in flutter with firebase authentication

final FirebaseAuth _auth = FirebaseAuth.instance;

Future<void> _signOut() async {
    await _auth.signOut();
    await _googleSignIn.signOut();
  }

Tags:

Dart Example