title: How to Signout a user in Flutter with Firebase authentication
body: <p>I have a problem signing out the current user from my app</p>
  
  <p>the method I am using is as follows:</p>
  
  <pre><code>....
  onPressed:_signOut
  //jump to function
  
  
    void _signOut() {
    FirebaseAuth.instance.signOut();
    FirebaseUser user = FirebaseAuth.instance.currentUser;
    //print('$user');
    runApp(
        new MaterialApp(
          home: new LoginPage(),
        )
  
    );
  }
  </code></pre>
  
  <p>So now when I press the button it should sign the user out and redirect them to the home page which they will have to login again, however, the redirecting happens but the user data would still be saved so when I press the button again it automatically sign in again with the last account. How can I remove user data so the app asks about their credentials each time they try to login after a logout ?</p>
  
  <p>I feel I am missing something in the linkage between pages and how their behavior change accordingly, but what is it ?</p>
  
  <p>Update: I use google sign in function with firebase authentication </p>
  
  <pre><code>   Future&lt;String&gt; _testSignInWithGoogle() async {
    final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
    final GoogleSignInAuthentication googleAuth =
    await googleUser.authentication;
    final FirebaseUser user = await _auth.signInWithGoogle(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );
    assert(user.email != null);
    assert(user.displayName != null);
    assert(!user.isAnonymous);
    assert(await user.getToken() != null);
  return 'signInWithGoogle succeeded: $user';
  }
  </code></pre>
  
  <p>My login page looks like this:</p>
  
  <pre><code>    class LoginPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
  
      return new Scaffold(
          appBar: new AppBar(
            title: new Text("Login"), backgroundColor: Colors.blue,),
          body: new Container(
              child: new Center(
                  child: new Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: &lt;Widget&gt;[
                      new IconButton(
                        icon: new Icon(Icons.account_box, color: Colors.red),
                        onPressed:  _signIn,
                        iconSize: 80.0,),
                      new Text("Google Signin")
                    ],
                  )
              )
          )
      );
    }
  }
  </code></pre>
  
  <p>Update: Changed _signOut() method to be async as follows:</p>
  
  <pre><code>    Future &lt;LoginPage&gt; _signOut()  async{
      await FirebaseAuth.instance.signOut();
  
      return new LoginPage();
  }
  </code></pre>
  
  <p>Now when I press on signout, it does not redirect me to the LoginPagae nor does it sign the user out.</p>