Flutter Firebase Authenticationの操作

2020年5月5日 Posted by PURGE

Firebase Authenticationへの登録

  FirebaseAuth firebaseAuth = FirebaseAuth.instance;
  DatabaseReference dbRef = FirebaseDatabase.instance.reference().child('Users');

    firebaseAuth
        .createUserWithEmailAndPassword(
          email: emailController.text,
          password: passwordController.text).then((result){
          dbRef.child(result.user.uid).set({
            'email': emailController.text,
          })

Firebase Authenticationへのログイン

  FirebaseAuth firebaseAuth = FirebaseAuth.instance;
    firebaseAuth.signInWithEmailAndPassword(
        email: emailController.text,
        password: passwordController.text)
        .then((result){
          Navigator.pushReplacement(
              context,
              MaterialPageRoute(builder: (context) => HomePage(uid: result.user.uid)),
          );
    })

Firebase Authentication存在確認

    FirebaseAuth.instance.currentUser().then((response) { }

Firebase Authenticationログアウト

              FirebaseAuth auth = FirebaseAuth.instance;
              auth.signOut().then((response){}
               

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です