使用者每次启动应用程式时,都必须先飘动Google Firebase登录

时间:2018-07-13 13:11:09

标签: firebase-authentication flutter google-signin

我正在尝试对Google登录使用Firebase身份验证,但是每次启动应用程序时我的登录过程都需要进行。如果用户已经登录一次然后转到主页,该怎么办。

import 'package:flutter/material.dart';
import 'sign_in.dart';
import 'dart:async';

class Login_page extends StatelessWidget {


Future<bool> _login_user()async{
final sign_in=await Sign_in_google.sign_with_google();
if(sign_in!=null){
  return true;
}
else{
  return false;
}
  }

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: new AppBar(
    title: new Text('Food Reviewer'),
  ),
  body: new Center(
    child: new RaisedButton(
      child: new Text('google sign in'),
      onPressed: ()async{
        bool result=await _login_user();
        result ? Navigator.of(context).pushNamed("home_page"):
        Scaffold.of(context).showSnackBar(new SnackBar(
          content: new Text('wrong email'),
        ));

      },
    ),
  ),
);
 }
}

0 个答案:

没有答案