title: How to solve "The property 'length' can't be unconditionally accessed because the receiver can be 'null'."
body: <pre><code>import 'package:bloc_sample/blocs/product_bloc.dart';
  import 'package:flutter/material.dart';
  
  import '../blocs/cart_bloc.dart';
  import '../models/cart.dart';
  
  class ProductListScreen extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(&quot;eCommerce&quot;),
          actions: [
            IconButton(
              icon: Icon(Icons.shopping_cart),
              onPressed: () =&gt; Navigator.pushNamed(context, &quot;/cart&quot;),
            )
          ],
        ),
        body: buildProductList(),
      );
    }
  
    buildProductList() {
      return StreamBuilder(
        initialData: productBloc.getAll(),
        stream: productBloc.getStream,
        builder: (context, snapshot) {
          return snapshot.data.length &gt; 0 //ERROR
              ? buildProductListItems(snapshot)
              : Center(
                  child: Text(&quot;No data&quot;),
                );
        },
      );
    }
  
    buildProductListItems(AsyncSnapshot snapshot) {
      return ListView.builder(
          itemCount: snapshot.data.length,
          itemBuilder: (BuildContext context, index) {
            final list = snapshot.data;
            return ListTile(
              title: Text(list[index].name),
              subtitle: Text(list[index].price.toString()),
              trailing: IconButton(
                icon: Icon(Icons.add_shopping_cart),
                onPressed: () {
                  cartBloc.addToCart(Cart(list[index], 1));
                },
              ),
            );
          });
    }
  }
  
  </code></pre>
  <p>The property 'length' can't be unconditionally accessed because the receiver can be 'null'. (Documentation)  Try making the access conditional (using '?.') or adding a null check to the target ('!').</p>
  <p>I tried &quot;?&quot; or &quot;!&quot; but its doesn't work. Can You help me? How can I solve this problem?</p>