I'm developing an app that manages glossary food items. I can't figure out what is the mistake I've done. Here's my code...

First, I've created a class called 'Product' that contains all the required fields like Product name, Product Image, item Type and quantity etc

**The model :**

```
class Product {
  String id;
  final String productName;
  final String itemType;
  final String productImage;
  final String purchasedDate;
  final String expiryDate;
  final String quantity;

  Product({
    this.id = '',
    required this.productName,
    required this.productImage,
    required this.itemType,
    required this.purchasedDate,
    required this.expiryDate,
    required this.quantity,
  });

  Map<String, dynamic> toJson() => {
        'id': id,
        'ProductImage': productImage,
        'ProductName': productName,
        'PurchasedDate': purchasedDate,
        'ExpiryDate': expiryDate,
        'ItemType': itemType,
        'Quantity': quantity,
      };

  static Product fromJson(Map<String, dynamic> json) => Product(
      productName: json['ProductName'],
      productImage: json['productImage'],
      itemType: json['ItemType'],
      purchasedDate: json['purchasedDate'],
      expiryDate: json['ExpiryDate'],
      quantity: json['Quantity']);
}

```

**The code for implementation :**

```
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:expire_x/utils/product.dart';
import 'package:flutter/material.dart';

class HomePageTwo extends StatefulWidget {
  const HomePageTwo({Key? key}) : super(key: key);

  @override
  State<HomePageTwo> createState() => _HomePageTwoState();
}

class _HomePageTwoState extends State<HomePageTwo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("home page"),
      ),
      body: StreamBuilder<List<Product>>(
        stream: readProduct(),
        builder: (context, snapshot) {
          if (snapshot.hasError) {
            return Text("Something went wrong> ${snapshot.error}");
          } else if (snapshot.hasData) {
            final product = snapshot.data!;
            return ListView(
              children: product.map(buildProduct).toList(),
            );
          } else {
            return Center(
              child: CircularProgressIndicator(),
            );
          }
        },
      ),
    );
  }

  Widget buildProduct(Product product) => ListTile(
        title: Text(product.productName),
      );

  Stream<List<Product>> readProduct() => FirebaseFirestore.instance
      .collection('Products')
      .snapshots()
      .map((snapshot) =>
          snapshot.docs.map((doc) => Product.fromJson(doc.data())).toList());

  Future CreateProduct() async {
    final docProduct = FirebaseFirestore.instance.collection('Products').doc();

    final product = Product(
      id: docProduct.id,
      productImage: 'ddd',
      productName: "productName",
      purchasedDate: "purchasedDate",
      expiryDate: "expiryDate",
      itemType: "itemType",
      quantity: "quantity",
    );
    final json = product.toJson();
    await docProduct.set(json);
  }
}

```

**The json response from firebase that I wanted :**
[json response](https://i.stack.imgur.com/YEIz6.png)

**And the error :**

type 'Null' is not a subtype of type 'String'

[In the emulator](https://i.stack.imgur.com/5CVeb.png)

I'm new to flutter. Can anyone please help me?