title: Flutter and Firestore: NoSuchMethodError: The method '...' was called on null
body: <p>i have a login page in my flutter app to authenticate and register users. When i want to save the user email-address to firestore (after register), i get the error:</p>
  
  <pre><code>flutter: Error: NoSuchMethodError: The method 'saveRegisterUserData' was called on null.
  Receiver: null
  Tried calling: saveRegisterUserData(email: "test@test.de", userID: "EVDnVFMkYeYd291Yzu2j2r8HLpC2")'
  </code></pre>
  
  <p>i have created a seperate dart-file for the Firestore Functions. It look like this:</p>
  
  <pre><code>import 'package:cloud_firestore/cloud_firestore.dart';
  import 'dart:async';
  
  abstract class BaseFire {
  Future &lt;void&gt; saveRegisterUserData({String userID, String email});
  }
  
  class Fire implements BaseFire {
   final Firestore firestore = new Firestore();
   DocumentReference usersdocuments;
  
   Future &lt;void&gt; saveRegisterUserData({String userID, String email}) async {
     usersdocuments = Firestore.instance.collection("Users").document(userID);
     Map&lt;String, String&gt; registerdata = &lt;String, String&gt;{
     "Email": email,
     };
     usersdocuments.setData(registerdata).whenComplete(() {
     return print("Document Added");
     }).catchError((error) =&gt; print(error));
   }
  }
  </code></pre>
  
  <p>i import this file in my login page und execute this function:</p>
  
  <pre><code>import '../Firebase/firestore.dart';
  
  class SignInPage extends StatefulWidget {
    SignInPage({this.firestore});
    final BaseFire firestore;
  
  @override
  State&lt;StatefulWidget&gt; createState() {
    return _SignInPageState();
    }
  }
  
  class _SignInPageState extends State&lt;SignInPage&gt; {
     String _email;
     String _password;
  
   ...
  
   void submitRegister() async {
     if (validateAndSave()) {
       try {
         String userId = await widget.auth.createUserWithEmailAndPassword(_email, _password);
         await widget.firestore.saveRegisterUserData(userID: userId, email: _email);
        } catch (error) {
          print(error);
       }
      }
     }
  }
  </code></pre>
  
  <p>Where is my mistake? Thank you for our help</p>