title: `Unhandled Exception: Invalid argument: Instance of '_$_Category'` While sending data to firestore form a freezed generated class
body: <p>I created two model classes with freezed. One class is having parameter of other class inside it. The problem started when I try to send data to firestore. This following error appears.</p>
  <pre class="lang-dart prettyprint-override"><code>E/flutter ( 6175): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument: Instance of '_$_Category'
  E/flutter ( 6175): #0      convertPlatformException
  package:cloud_firestore_platform_interface/…/utils/exception.dart:14
  E/flutter ( 6175): #1      MethodChannelDocumentReference.set
  package:cloud_firestore_platform_interface/…/method_channel/method_channel_document_reference.dart:44
  E/flutter ( 6175): &lt;asynchronous suspension&gt;
  E/flutter ( 6175): #2      _JsonCollectionReference.add
  package:cloud_firestore/src/collection_reference.dart:109
  E/flutter ( 6175): &lt;asynchronous suspension&gt;
  E/flutter ( 6175): #3      _WithConverterCollectionReference.add
  package:cloud_firestore/src/collection_reference.dart:180
  E/flutter ( 6175): &lt;asynchronous suspension&gt;
  E/flutter ( 6175): #4      _HomeScreenState.product
  package:mr_grocery/home/home_screen.dart:45
  E/flutter ( 6175): &lt;asynchronous suspension&gt;
  </code></pre>
  <p>Model classes</p>
  <ol>
  <li>Product (which has parameter of Category class)</li>
  </ol>
  <pre class="lang-dart prettyprint-override"><code>
  @freezed
  class Product with _$Product {
    const factory Product({
      required int amount,
      required List&lt;Category&gt; categories, // Category class generated by freezed
      required String description,
      required List&lt;String&gt; images,
      required bool inStock,
      required String name,
      required String quantity,
      dynamic soldQuantity,
      dynamic createdAt,
      dynamic updatedAt,
      bool? exclusive,
    }) = _Product;
  
    factory Product.fromJson(Map&lt;String, dynamic&gt; json) =&gt;
        _$ProductFromJson(json);
  }
  </code></pre>
  <ol start="2">
  <li>Category</li>
  </ol>
  <pre class="lang-dart prettyprint-override"><code>@freezed
  class Category with _$Category {
    const factory Category({
      required String image,
      required String name,
      // @_ColorSerlizeable() required Color? color,
    }) = _Category;
  
    factory Category.fromJson(Map&lt;String, dynamic&gt; json) =&gt;
        _$CategoryFromJson(json);
  }
  </code></pre>
  <p>Using <code>withConverter</code> from Firestore package</p>
  <pre class="lang-dart prettyprint-override"><code>  CollectionReference&lt;Product&gt; products() {
      const path = FirebasePaths.products;
      return _firestore.collection(path).withConverter&lt;Product&gt;(
            fromFirestore: (snapshot, options) =&gt; Product.fromJson(
              snapshot.data() ?? const {},
            ),
            toFirestore: (value, options) =&gt; value.toJson(),
          );
    }
  </code></pre>
  <p><strong>build.yaml</strong></p>
  <pre><code>targets:
    $default:
      builders:
        json_serializable:
          options:
            # Options configure how source code is generated for every
            # `@JsonSerializable`-annotated class in the package.
            #
            # The default value for each is listed.
            any_map: false
            checked: false
            constructor: &quot;&quot;
            create_factory: true
            create_to_json: true
            disallow_unrecognized_keys: false
            explicit_to_json: true // -- Specified to true
            field_rename: none
            generic_argument_factories: false
            ignore_unannotated: false
            include_if_null: true
  </code></pre>