title: error: The operator '[]' isn't defined for the type 'DocumentSnapshot'
body: <p>The code was working fine , but when I updated my dependencies I started getting the following errors:</p>
  <ol>
  <li>error: The operator '[]' isn't defined for the type 'DocumentSnapshot'</li>
  <li>error: The expression doesn't evaluate to a function, so it can't be invoked. (invocation_of_non_function_expression
  <a href="https://i.stack.imgur.com/2lTyI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2lTyI.png" alt="error: The operator '[]' isn't defined for the type 'DocumentSnapshot'." /></a>
  <a href="https://i.stack.imgur.com/TF5st.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TF5st.png" alt="error: The expression doesn't evaluate to a function, so it can't be invoked. (invocation_of_non_function_expression " /></a></li>
  </ol>
  <p><strong>here is the  code:</strong></p>
  <pre><code>import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'package:fluttertoast/fluttertoast.dart';
  import 'package:google_sign_in/google_sign_in.dart';
  import 'package:shared_preferences/shared_preferences.dart';
  import 'package:za/pages/signup.dart';
  import 'home.dart';
  
  
  class Login extends StatefulWidget {
    @override
    _LoginState createState() =&gt; _LoginState();
  }
  
  class _LoginState extends State&lt;Login&gt; {
    final GoogleSignIn googleSignIn = new GoogleSignIn();
    final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
    final _formKey = GlobalKey&lt;FormState&gt;();
    TextEditingController _emailTextController = TextEditingController();
    TextEditingController _passwordTextController = TextEditingController();
    SharedPreferences preferences;
    bool loading = false;
    bool islogedin = false;
    bool hidepass = true;
  
    @override
    void initState() {
      super.initState();
      isSignedIn();
    }
  
    void isSignedIn() async {
      setState(() {
        loading = true;
      });
  
  
      await firebaseAuth.currentUser().then((user){
        if (user!=null){
          setState(() =&gt; islogedin= true);
        }
      });
      if (islogedin == true) {
        Navigator.pushReplacement(
            context, MaterialPageRoute(builder: (context) =&gt; HomePage()));
      }
      setState(() {
        loading = false;
      });
    }
  
    Future handleSignIn() async {
      preferences = await SharedPreferences.getInstance();
      setState(() {
        loading = true;
      });
  
      final GoogleSignInAccount googleUser = await googleSignIn.signIn();
      final GoogleSignInAuthentication googleAuth =
          await googleUser.authentication;
  
      final AuthCredential credential = GoogleAuthProvider.getCredential(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );
      User firebaseUser =
          (await firebaseAuth.signInWithCredential(credential)).user;
  
      if (firebaseUser != null) {
        final QuerySnapshot result = await Firestore.instance
            .collection(&quot;users&quot;)
            .where(&quot;id&quot;, isEqualTo: firebaseUser.uid)
            .get();
        final List&lt;DocumentSnapshot&gt; documents = result.docs;
        if (documents.length == 0) {
          // insert the user to our collection
          FirebaseFirestore.instance
              .collection(&quot;users&quot;)
              .doc(firebaseUser.uid)
              .set({
            &quot;id&quot;: firebaseUser.uid,
            &quot;username&quot;: firebaseUser.displayName,
            &quot;profilePicture&quot;: firebaseUser.photoURL
          });
          await preferences.setString(&quot;id&quot;, firebaseUser.uid);
          await preferences.setString(&quot;username&quot;, firebaseUser.displayName);
          await preferences.setString(&quot;photoUrl&quot;, firebaseUser.displayName);
        } else {
          await preferences.setString(&quot;id&quot;, documents[0].data['id']);
          await preferences.setString(&quot;username&quot;, documents[0].data['username']);
          await preferences.setString(&quot;photoUrl&quot;, documents[0].data['photoUrl']);
        }
        Fluttertoast.showToast(msg: &quot;Login was successful&quot;);
        setState(() {
          loading = false;
        });
      } else {
  
        Fluttertoast.showToast(msg: &quot;Login failed&quot;);
      }
    }
  </code></pre>