title: type 'MethodChannelDocumentReference' is not a subtype of type 'DocumentReference' in type cast
body: <p>I'm updating my project using firestore and its the first time that I has this type of error.
  Its very stange for me, I use firestore how the documentation saids and in other parts of my app Firestore don't had any error,
  but in this part I use cloud functions to create a document and insert its reference in other. After I need to obtain the DocumentId but its said me this error "type 'MethodChannelDocumentReference' is not a subtype of type 'DocumentReference' in type cast"
  I leave some screenshots.</p>
  
  <p><a href="https://i.stack.imgur.com/G82IN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G82IN.png" alt="firebase user document =&gt;coupon=&gt;reference as reference"></a></p>
  
  <p>This is my code in cloud functions: </p>
  
  <pre><code>exports.generateUserCode = functions.https.onCall(async (data, context) =&gt; {
    const { uid } = data;
    let coupon = shortid.generate();
    let user = firestore.doc(`users/${uid}`);
    try {
      await firestore
        .collection("coupons")
        .doc(coupon)
        .set({
          owner: user,
          type: 0,
          value: 10,
          isPercentage: false,
          usersUsedIt: 0
        });
      await user.update({
        coupon: {
          reference: firestore.doc(`coupons/${coupon}`),
          uses: 0
        }
      });
      return {
        status: true,
        message: "codigo de invitacion generado",
        code: coupon
      };
    } catch (e) {
      console.log("error", e);
      return {
        status: false,
        message: "algo salio mal",
        code: null
      };
    }
  });
  </code></pre>
  
  <p>This is the flutter code: </p>
  
  <pre><code>@override
    Future&lt;UserModel&gt; getUser() async {
      try {
        final authUser = await _auth.currentUser();
        if (authUser != null) {
          final user = await _firestore.document('users/${authUser.uid}').get();
          if (!user.data.containsKey('coupon') || user.data['coupon'] == null) {
            final couponCode = await _generateCode(authUser.uid);
            return UserModel.fromData(authUser, couponCode);
          } else {
            final coupon = Map&lt;String, dynamic&gt;.from(user.data['coupon']);
            final couponRef = coupon['reference'] as DocumentReference;
            return UserModel.fromData(authUser, couponRef.documentID);
          }
        }
        return null;
      } catch (e) {
        log(e.toString(), error: e);
        throw ServerException();
      }
    }
  </code></pre>
  
  <p>And this appears when I try to debug the code:</p>
  
  <pre><code>type 'MethodChannelDocumentReference' is not a subtype of type 'DocumentReference' in type cast
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hbFeU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hbFeU.png" alt="MethodChannelDocumentReference"></a></p>