title: Flutter GetX package Firebase Auth and FireStore "null check operator used on a null value"
body: <p>First of all, I'm asking a question for the first time, I'm sorry if I'm asking incorrectly and incompletely, I will give you the information you want immediately.</p>
  <p>Hey, I was following the tutorial in this video but I am getting an error like this.
  video tutorial: <a href="https://www.youtube.com/watch?v=BiV0DcXgk58&amp;t=314s&amp;ab_channel=TadasPetra" rel="nofollow noreferrer">https://www.youtube.com/watch?v=BiV0DcXgk58&amp;t=314s&amp;ab_channel=TadasPetra</a></p>
  <p>Error is this:
  <a href="https://i.stack.imgur.com/ub3wl.png" rel="nofollow noreferrer">Error simulator picture</a></p>
  <p>I am getting this error, but the account is created in firebase Auth and the data I want is saved in FireStore database.</p>
  <p>Flutter version: 2.2.3</p>
  <p><strong>pubspec.yaml</strong></p>
  <pre><code>  cloud_firestore: ^0.13.5
    firebase_core: ^0.4.5
    firebase_storage: ^3.1.6
    get: ^4.3.8
  </code></pre>
  <p>Error debug console text</p>
  <pre><code>[GETX] Instance &quot;AuthController&quot; has been created
  [GETX] Instance &quot;AuthController&quot; has been initialized
  [GETX] Instance &quot;GetMaterialController&quot; has been created
  [GETX] Instance &quot;GetMaterialController&quot; has been initialized
  
  ════════ Exception caught by widgets library ═══════════════════════════════════
  The following _CastError was thrown building Root:
  Null check operator used on a null value
  
  The relevant error-causing widget was
  Root
  lib/main.dart:20
  When the exception was thrown, this was the stack
  #0      GetXState.initState
  package:get/…/rx_flutter/rx_getx_widget.dart:78
  #1      StatefulElement._firstBuild
  package:flutter/…/widgets/framework.dart:4711
  #2      ComponentElement.mount
  package:flutter/…/widgets/framework.dart:4548
  #3      Element.inflateWidget
  package:flutter/…/widgets/framework.dart:3611
  #4      Element.updateChild
  package:flutter/…/widgets/framework.dart:3363
  </code></pre>
  <p><em><strong>All files</strong></em></p>
  <p>Main.dart code</p>
  <pre><code>    void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    const MyApp({Key key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return GetMaterialApp(
        debugShowCheckedModeBanner: false,
        initialBinding: AuthBinding(),
        theme: ThemeData(scaffoldBackgroundColor: bgColor),
        home: Root(),
      );
    }
  }
  </code></pre>
  <p>Root.dart code</p>
  <pre><code>class Root extends GetWidget&lt;AuthController&gt; {
    @override
    Widget build(BuildContext context) {
      return GetX(
        initState: (_) async {
          Get.put&lt;UserController&gt;(UserController());
        },
        builder: (_) {
          if (Get.find().user?.uid != null) {
            return SMBottomNavBar();
          } else {
            return SignInScreen();
          }
        },
      );
    }
  }
  </code></pre>
  <p>userController.dart</p>
  <pre><code>class UserController extends GetxController {
    Rx&lt;UserModel&gt; _userModel = UserModel().obs;
  
    UserModel get user =&gt; _userModel.value;
  
    set user(UserModel value) =&gt; this._userModel.value = value;
  
    void clear() {
      _userModel.value = UserModel();
    }
  }
  </code></pre>
  <p>authController.dart</p>
  <pre><code>class AuthController extends GetxController {
    FirebaseAuth _auth = FirebaseAuth.instance;
    Rxn&lt;FirebaseUser&gt; _firebaseUser = Rxn&lt;FirebaseUser&gt;();
  
    FirebaseUser get user =&gt; _firebaseUser.value;
  
    @override
    onInit() {
      _firebaseUser.bindStream(_auth.onAuthStateChanged);
    }
  
    void createUserAccount(String userName, String email, String password) async {
      try {
        AuthResult _authResult = await _auth.createUserWithEmailAndPassword(
            email: email.trim(), password: password);
        //create user in database.dart
        UserModel _user = UserModel(
           userID: _authResult.user.uid, userName: userName, userEmail: email
        );
        if (await DatabaseServices().createNewUser(_user)) {
          Get.find&lt;UserController&gt;().user = _user;
          Get.back();
        }
      } catch (e) {
        Get.snackbar(
          &quot;Error creating Account&quot;,
          e.message,
        );
      }
    }
  
    void logInUser(String email, String password) async {
      try {
        AuthResult _authResult = await _auth.signInWithEmailAndPassword(
            email: email.trim(), password: password);
        Get.find&lt;UserController&gt;().user =
            await DatabaseServices().getUser(_authResult.user.uid);
      } catch (e) {
        Get.snackbar(
          &quot;Error signing in&quot;,
          e.message,
          
        );
      }
    }
  
    void logOutUser() async {
      try {
        await _auth.signOut();
        Get.find&lt;UserController&gt;().clear();
      } catch (e) {
        Get.snackbar(
          &quot;Error signing out&quot;,
          e.message,
          
        );
      }
    }
  }
  </code></pre>
  <p>authBinding.dart</p>
  <pre><code>class AuthBinding extends Bindings {
    @override
    void dependencies() {
      Get.put&lt;AuthController&gt;(AuthController(), permanent: true);
    }
  }
  </code></pre>
  <p>user.dart(Model)</p>
  <pre><code>class UserModel {
    String userID;
    String userEmail;
    String userName;
    String userDisplayName;
    String userProfilePhotoURL;
    String userBioText;
    int userScore;
  
    UserModel(
        {this.userID,
        this.userEmail,
        this.userName,
        this.userDisplayName,
        this.userProfilePhotoURL,
        this.userBioText,
        this.userScore});
  
    UserModel.fromDocumentSnapshot(DocumentSnapshot doc) {
      userID = doc.documentID;
      userEmail = doc['userEmail'];
      userName = doc['userName'];
      userDisplayName = doc['userDisplayName'];
      userProfilePhotoURL = doc['userProfilePhotoURL'];
      userBioText = doc['userBioText'];
      userScore = doc['userScore'];
    }
  }
  </code></pre>