title: The argument type 'Stream<dynamic>' can't be assigned to the parameter type 'Stream<QuerySnapshot>?'
body: <p>I am getting an error &quot;The argument type 'Stream' can't be assigned to the parameter type 'Stream?&quot; while running this code:</p>
  <pre><code>import 'package:app_using_database/post.dart';
  import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  
  class Home extends StatelessWidget {
    Stream postStream =
        FirebaseFirestore.instance.collection('posts').snapshots();
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Container(
          padding: EdgeInsets.symmetric(horizontal: 10),
          child: SafeArea(
            child: StreamBuilder&lt;QuerySnapshot&gt;(
              stream: postStream,
              builder:
                  (BuildContext context, AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) {
                if (snapshot.hasError) {
                  return Text('Something went wrong');
                }
  
                if (snapshot.connectionState == ConnectionState.waiting) {
                  return Text(&quot;Loading&quot;);
                }
  
                return new ListView(
                  children: snapshot.data!.docs.map((DocumentSnapshot document) {
                    Map&lt;String, dynamic&gt; data =
                        document.data() as Map&lt;String, dynamic&gt;;
                    return Post();
                  }).toList(),
                );
              },
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>I am trying to get posts from firebase but this error appears. It also says</p>
  <ul>
  <li>'Stream' is from 'dart:async'.</li>
  <li>'QuerySnapshot' is from 'package:cloud_firestore/cloud_firestore.dart'</li>
  </ul>