title: Flutter The argument type 'StreamTransformer<dynamic, dynamic>' can't be assigned to the parameter type StreamTransformer<QuerySnapshot List<Message>>
body: <p>I am trying to build a chat application using Flutter &amp; Firebase I took below code from Github and used it on my project. On an earlier version of Flutter, it was working, on 2.0 it is showing the following error: <code>The argument type 'StreamTransformer&lt;dynamic, dynamic&gt;' can't be assigned to the parameter type 'StreamTransformer&lt;QuerySnapshot, List&lt;Message&gt;&gt;'</code></p>
  <p>The error is triggered by the following line:</p>
  <p><code>.transform(Utils.transformer(User.fromJson));</code></p>
  <p>Full code:</p>
  <pre><code>class FirebaseApi {
    static Stream&lt;List&lt;User&gt;&gt; getUsers() =&gt; FirebaseFirestore.instance
        .collection('users')
        // .collection('ch ats')
        .orderBy(UserField.timestamp, descending: true)
        .snapshots()
        .transform(Utils.transformer(User.fromJson));
  
    static Future uploadMessage(String idUser, String message) async {
      final refMessages =
          FirebaseFirestore.instance.collection('chats/$idUser/messages');
  
      final newMessage = Message(
        // idUser: myId,
        idUser: Globals.auth.currentUser!.uid,
        // urlAvatar: myUrlAvatar,
        urlAvatar: ChatPageState.photoUrl.toString(),
        // username: myUsername,
        username: ChatPageState.displayName.toString(),
        message: message,
        createdAt: DateTime.now(),
      );
      await refMessages.add(newMessage.toJson());
  
      final refUsers = FirebaseFirestore.instance.collection('users');
  
      await refUsers.doc(idUser).update({UserField.timestamp: DateTime.now()});
    }
  
    static Stream&lt;List&lt;Message&gt;&gt; getMessages(String idUser) {
      return FirebaseFirestore.instance
          .collection('chats/$idUser/messages')
          .orderBy(MessageField.createdAt, descending: true)
          .snapshots()
          .transform(Utils.transformer(Message.fromJson));
    }
  
  }
  
  class Utils {
    static StreamTransformer transformer&lt;T&gt;(
            T Function(Map&lt;String, dynamic&gt; json) fromJson) =&gt;
        StreamTransformer&lt;QuerySnapshot, List&lt;T&gt;&gt;.fromHandlers(
          handleData: (QuerySnapshot data, EventSink&lt;List&lt;T&gt;&gt; sink) {
            final snaps = data.docs.map((doc) =&gt; doc.data()).toList();
            final users = snaps.map((json) =&gt; fromJson(json)).toList();
  
            sink.add(users);
          },
        );
  
    static DateTime toDateTime(Timestamp value) {
      // if (value == null);
  
      return value.toDate();
    }
  
    static dynamic fromDateTimeToJson(DateTime date) {
      if (date == null) return null;
  
      return date.toUtc();
    }
  }
  </code></pre>