title: The getter 'email' was called on null
body: <p>I'm trying to make a chat between two people using Flutter and Firebase but I'm facing an error when I connect into my app using Firebase's signInWithEmailAndPassword, it tells me:</p>
  
  <blockquote>
    <p>The getter 'email' was called on null. Receiver: null Tried calling:
    email</p>
  </blockquote>
  
  <p>And Flutter also tells me the error come from the MaterialApp widget from my main.dart which doesn't help me to find the error..</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:social/responsive/size_config.dart';
  import 'settings.dart';
  import 'home.dart';
  
  final _firestore = Firestore.instance;
  FirebaseUser loggedInUser;
  
  
  class ActivityFeed extends StatefulWidget {
    static const String id = 'activity_feed_screen';
    @override
    _ActivityFeedState createState() =&gt; _ActivityFeedState();
  }
  
  class _ActivityFeedState extends State&lt;ActivityFeed&gt; {
    final _auth = FirebaseAuth.instance;
  
    @override
    void initState() {
      super.initState();
      getCurrentUser();
    }
  
    void getCurrentUser() async {
      try {
        final user = await _auth.currentUser();
        if (user != null) {
          loggedInUser = user;
        }
      } catch (e) {
        print(e);
      }
    }
  
    @override
    Widget build(BuildContext context) {
  
      return Scaffold(
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: &lt;Widget&gt;[
            Expanded(
              child: Container(
                color: Colors.red,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: &lt;Widget&gt;[
                      UserInfo(),
                      FlatButton(
                        child: Icon(
                          Icons.settings,
                          color: Colors.white,
                        ),
                        onPressed: () {
                          Navigator.pushNamed(context, Settings.id);
                        },
                      ),
                    FlatButton(
                      child: Icon(
                        Icons.not_interested,
                        color: Colors.white,
                      ),
                      onPressed: () {
                        _auth.signOut();
                        Navigator.pushNamed(context, Home.id);
                      },
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      );
    }
  }
  
  class UserInfo extends StatefulWidget {
    @override
    _UserInfoState createState() =&gt; _UserInfoState();
  }
  
  class _UserInfoState extends State&lt;UserInfo&gt; {
  
    String email = loggedInUser.email;
    String username;
  
    @override
    void initState() {
      super.initState();
      getUsername();
    }
  
    void getUsername() async {
      DocumentReference docRef = _firestore.collection('users').document(email);
      docRef.get().then((snapshot) {
        if (snapshot.exists) {
          username = snapshot.data['username'];
        }
      });
    }
  
    @override
    Widget build(BuildContext context) {
      SizeConfig().init(context);
      return Column(
          children: &lt;Widget&gt;[
            Text(
              'Welcome $username',
              style: TextStyle(
                  fontFamily: 'Amatic',
                  fontSize: SizeConfig.safeBlockHorizontal * 10),
            ),
          ],
        )
      ;
    }
  }
  </code></pre>
  
  <p>So basically what I am just trying to display 'Welcome' + the username, but it doesn't want,
  my Firebase Database have one collection named 'users', where the document names are the email the user used when he created his account.</p>
  
  <p>All the Register/Log-In process seems to work fine.</p>
  
  <p>If someone has a clue of what is happening that would be awesome, thanks.</p>