title: Updated to cloud_firestore 2.2.0 and cannot figure out the error
body: <p>Refactoring my code, I updated to</p>
  <pre><code>dependencies:
    flutter:
      sdk: flutter
    firebase_core: ^1.2.0
    firebase_auth: ^1.2.0
    cloud_firestore: ^2.2.0
    cloud_functions: ^1.1.0
    ...
  </code></pre>
  <p><em>e.g. cloud_firestore from 1.0.4 to 2.2.0</em></p>
  <p>I have a User class</p>
  <pre class="lang-dart prettyprint-override"><code>import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:flutter/widgets.dart';
  import 'package:mypckg/services/database.dart';
  
  class User {
    final String id;
    final String email;
    final String displayName;
    final String language;
    final List affiliatedOrganizations;
    final bool isAdmin;
    final bool isEditor;
  
    const User(
        {this.id = &quot;&quot;,
        this.email = &quot;&quot;,
        this.displayName = &quot;&quot;,
        this.language = &quot;&quot;,
        this.affiliatedOrganizations = const [],
        this.isAdmin = false,
        this.isEditor = false});
  
    factory User.fromFirestore(DocumentSnapshot doc) {
      Map data = doc.data()!;
      return User(
        id: doc.id,
        email: data['email'],
        displayName: data['displayName'] ?? '',
        language: data['language'] ?? '',
        affiliatedOrganizations: data['affiliatedOrganizations'] ?? [],
        isAdmin: data['isAdmin'] ?? false,
        isEditor: data['isEditor'] ?? false,
      );
    }
  }
  </code></pre>
  <p>and later I would like to get some data</p>
  <pre class="lang-dart prettyprint-override"><code>      ...
        var userData = await DatabaseService(uid: user.uid)
            .getUserData()
            .then((value) =&gt; value.data());
  
        local.User fullLocalUser = local.User(
            id: user.uid,
            email: user.email,
            displayName: userData!['displayName'] ?? &quot;&quot;, // &lt;-- error referencing this line
            language: userData['language'] ?? &quot;&quot;,
            affiliatedOrganizations: userData['affiliatedOrganizations'] ?? [],
            isAdmin: (await _userClaims)!['admin'] == true,
            isEditor: (await _userClaims)!['editor'] == true);
  
        return fullLocalUser;
        ...
  </code></pre>
  <p>Relevant extract from DatabaseService</p>
  <pre class="lang-dart prettyprint-override"><code>class DatabaseService {
    final String uid;
    DatabaseService({this.uid = &quot;&quot;});
  
    final CollectionReference usersCollection =
        FirebaseFirestore.instance.collection('users');
    
    ...
    Future&lt;DocumentSnapshot&gt; getUserData() async {
      print(&quot;get user data&quot;);
      return await usersCollection.doc(uid).get();
    }
    ...
  </code></pre>
  <p>When I compile the code, it results in</p>
  <pre><code>Error: The operator '[]' isn't defined for the class 'Object'.
   - 'Object' is from 'dart:core'.
  Try correcting the operator to an existing operator, or defining a '[]' operator.
            displayName: userData!['displayName'] ?? &quot;&quot;,
  </code></pre>
  <p>I found out, that in regards to <a href="https://pub.dev/packages/cloud_firestore/changelog" rel="nofollow noreferrer">https://pub.dev/packages/cloud_firestore/changelog</a> &quot;DocumentReference, CollectionReference, Query, DocumentSnapshot, CollectionSnapshot, QuerySnapshot, QueryDocumentSnapshot, Transaction.get, Transaction.set and WriteBatch.set now take an extra generic parameter. (#6015).&quot; But I cannot figure out what I have to change now, that the code will work again :(</p>