title: Null error when I want my firebase user id with currentUser()
body: <p><strong>Error</strong></p>
  
  <p>NoSuchMethodError: The method 'currentUser' was called on null.</p>
  
  <p>Receiver: null</p>
  
  <p>Tried calling: currentUser()</p>
  
  <p>I'm interesting in know where i need to using this code:</p>
  
  <pre><code>String _uid = '';
        void initState() {
          super.initState();
          auth.currentUser().then((userId) {
            setState(() {
              _uid = userId;
            });
          });
        }
  </code></pre>
  
  <p>This code is from the home_page.dart (see below)</p>
  
  <p>I had also tried to using:</p>
  
  <p>widget.auth.current....</p>
  
  <p><strong>root_page</strong></p>
  
  <p>In bottom of the file i had tried different approach.
  Instead of HomePage then _HomePageState(comments out)</p>
  
  <pre><code>class RootPage extends StatefulWidget {
  
    RootPage({this.auth});
    final BaseAuth auth;
  
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; new _RootPageState();
  
  }
  
  enum AuthStatus {
    notSignedIn,
    signedIn
  }
  
  class _RootPageState extends State&lt;RootPage&gt;{
  
    AuthStatus authStatus = AuthStatus.notSignedIn;
  
    @override
    void initState() {
      super.initState();
      widget.auth.currentUser().then((userId) {
        setState(() {
          authStatus = userId == null ? AuthStatus.notSignedIn : AuthStatus.signedIn;
        });
      });
    }
  
    void _signedIn(){
      setState(() {
        authStatus = AuthStatus.signedIn;
      });
    }
  
    void _signedOut() {
      setState(() {
        authStatus = AuthStatus.notSignedIn;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      switch(authStatus) {
        case AuthStatus.notSignedIn:
          return new LoginPage(
            auth: widget.auth,
            onSignedIn: _signedIn,
          );
        case AuthStatus.signedIn:
          /*
          return new HomePageState(
            auth: widget.auth,
            onSignedOut: _signedOut,
          );
          */
          return new HomePage(
            auth: widget.auth,
            onSignedOut: _signedOut,
          );
      }
    }
  }
  </code></pre>
  
  <p><strong>auth.dart</strong></p>
  
  <p>This is the class I'm using to get current user from auth. </p>
  
  <pre><code>abstract class BaseAuth{
    Future&lt;String&gt; signInWithEmailAndPassword(String email, String password);
    Future&lt;String&gt; createUserWithEmailAndPassword(String email, String password);
    Future&lt;String&gt; currentUser();
    Future&lt;void&gt; signOut();
  }
  
  class Auth implements BaseAuth{
  
    final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
  
    Future&lt;String&gt; signInWithEmailAndPassword(String email, String password) async {
      FirebaseUser user = await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password);
      return user.uid;
    }
  
    Future&lt;String&gt; createUserWithEmailAndPassword(String email, String password) async {
      FirebaseUser user = await _firebaseAuth.createUserWithEmailAndPassword(email: email, password: password);
      return user.uid;
    }
  
    Future&lt;String&gt; currentUser() async {
      FirebaseUser user = await _firebaseAuth.currentUser();
      return user.uid;
    }
  
    Future&lt;void&gt; signOut() async {
      return _firebaseAuth.signOut();
    }
  
  }
  </code></pre>
  
  <p><strong>home_page.dart</strong></p>
  
  <p>I had tried different things in this file but get different errors.</p>
  
  <pre><code>class HomePage extends StatefulWidget {
  
    HomePage({this.auth, this.onSignedOut});
  
    final BaseAuth auth;
    final VoidCallback onSignedOut;
  
    void _signOut() async {
      try {
        await auth.signOut();
        onSignedOut();
      } catch (e) {
        print(e);
      }
    }
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; new _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
  /*
    _HomePageState({this.auth, this.onSignedOut});
    final BaseAuth auth;
    final VoidCallback onSignedOut;
    */
    //final BaseAuth auth;
  
    String _uid = '';
  
    @override
    void initState() {
      super.initState();
      auth.currentUser().then((userId) {
        setState(() {
          _uid = userId;
        });
      });
    }
  </code></pre>