파이어베이스 구글 로그인 연동

정재한·2022년 8월 1일
0

앱개발

목록 보기
4/23
class LoginPage extends StatelessWidget {
  LoginPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
          Text('Instagram Clone',
          style: TextStyle(fontSize: 40,fontWeight: FontWeight.bold),),
          Padding(padding: EdgeInsets.all(50),
          ),
          SignInButton(Buttons.Google, onPressed: (){
            signWithGoogle().then((user){
              print('object');
            });
          })
        ]),
      ),
    );
  }
 Future <UserCredential> signWithGoogle() async {
  final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
  final GoogleSignInAuthentication googleAuth = (await googleUser?.authentication)!;
   final credential = GoogleAuthProvider.credential(
    accessToken: googleAuth.accessToken,
    idToken: googleAuth.idToken
  );
  return await FirebaseAuth.instance.signInWithCredential(credential);
 }
}

0개의 댓글

관련 채용 정보