title: The argument type 'Object?' can't be assigned to the parameter type 'Map<String, dynamic>'
body: <p>I am trying to retrieve data from a document in Firestore using a Widget. I used this in the past, I guess with a different version of Dart or flutter, and it worked. Now this is showing the following error when I use  <code>(doc.data())</code>
  <strong>The argument type 'Object?' can't be assigned to the parameter type 'Map&lt;String, dynamic&gt;'</strong></p>
  <p>Here's the code</p>
  <pre><code>DriverProvider driverProvider;
  
  void getDriverInfo() {
      Stream&lt;DocumentSnapshot&gt; driverStream =
          driverProvider!.getbyIdStream(FirebaseAuth.instance.currentUser!.uid);
      driverStream.listen((DocumentSnapshot doc) {
        driver = Driver.fromJson(doc.data());
      });
    }
  
  </code></pre>
  <p>Here's where  driverProvider! comes from</p>
  <pre><code>import 'package:brokerdrivers/models/user-models.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  
  class DriverProvider {
    CollectionReference? _ref;
  
    DriverProvider() {
      _ref = FirebaseFirestore.instance.collection('Drivers');
    }
  
    Future? create(Driver driver) {
      String? errorMessage;
  
      try {
        return _ref!.doc(driver.id).set(driver.toJson());
      } catch (e) {
        print(e);
        errorMessage = e.toString();
        return Future.error(errorMessage);
      }
    }
  
    Stream&lt;DocumentSnapshot&gt; getbyIdStream(String id) {
      return _ref!.doc(id).snapshots(includeMetadataChanges: true);
    }
  }
  
  
  
  </code></pre>
  <p>and this is where <code>getbyIdStream</code> comes from</p>
  <pre><code>
    Stream&lt;DocumentSnapshot&gt; getbyIdStream(String id) {
      return _ref!.doc(id).snapshots(includeMetadataChanges: true);
    } 
  
  </code></pre>
  <p>This is my Json model</p>
  <pre><code>import 'dart:convert';
  
  Driver driverFromJson(String str) =&gt; Driver.fromJson(json.decode(str));
  
  String driverToJson(Driver data) =&gt; json.encode(data.toJson());
  
  class Driver {
    Driver({
      required this.id,
      required this.username,
      required this.email,
      required this.truck,
      required this.carrier,
      required this.insurance,
    });
  
    String id;
    String username;
    String email;
    String truck;
    String carrier;
    String insurance;
  
    factory Driver.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Driver(
          id: json[&quot;id&quot;],
          username: json[&quot;username&quot;],
          email: json[&quot;email&quot;],
          truck: json[&quot;truck&quot;],
          carrier: json[&quot;carrier&quot;],
          insurance: json[&quot;insurance&quot;],
        );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
          &quot;id&quot;: id,
          &quot;username&quot;: username,
          &quot;email&quot;: email,
          &quot;truck&quot;: truck,
          &quot;carrier&quot;: carrier,
          &quot;insurance&quot;: insurance,
        };
  }
  
  
  </code></pre>
  <p>and this is the line with the error</p>
  <pre><code>driver = Driver.fromJson(doc.data());
  </code></pre>
  <p>Thanks all for the help.</p>