title: flutter "could not generate 'fromJson' code for Type" error on Nullable
body: <p>I upgraded my project to Null-Safety but I'm getting an error when I define a property as null when running the build_runner:</p>
  <pre class="lang-dart prettyprint-override"><code>@JsonKey()
  late Guid? colonizedStellarObjectId;
  </code></pre>
  <p>The type Guid is from <a href="https://pub.dev/packages/flutter_guid" rel="nofollow noreferrer">here</a>, but I modified it to support null-safety:</p>
  <pre class="lang-dart prettyprint-override"><code>import 'package:uuid/uuid.dart';
  import 'package:validators/validators.dart';
  
  /// Class that emulates as closely as possible the C# Guid type.
  class Guid {
    static const String _defaultGuid = &quot;00000000-0000-0000-0000-000000000000&quot;;
  
    /// The Guid whose value is the default sequence of characters that represent a 'zero-value' UUID in .Net &quot;00000000-0000-0000-0000-000000000000&quot;
    static Guid get defaultValue =&gt; new Guid(_defaultGuid);
  
    String? _value;
  
    /// Constructor, expects a valid UUID and will throw an exception if the value provided is invalid.
    Guid(String v) {
      _failIfNotValidGuid(v);
      _value = v;
    }
  
    /// Generates a new v4 UUID and returns a GUID instance with the new UUID.
    static Guid get newGuid {
      return new Guid(Uuid().v4());
    }
  
    /// Checks whether a value is a valid Guid
    /// Returns false if 'guid' is null or has an invalid value
    /// Returns true if guid is valid
    static bool isValid(Guid? guid) {
      if (guid == null) {
        return false;
      } else {
        return isUUID(guid.value);
      }
    }
  
    _failIfNotValidGuid(String? v) {
      if (v == null || v.isEmpty) {
        v = _defaultGuid;
      }
      final isInvalid = isUUID(v) == false;
      if (isInvalid) {
        throw new FlutterGuidError(&quot;Value '$v' is not a valid UUID&quot;);
      }
    }
  
    /// Gets the UUID value contained by the Guid object as a string.
    String get value {
      if (_value == null || _value!.isEmpty) {
        return _defaultGuid;
      } else {
        return _value!;
      }
    }
  
    /// Performs a case insensitive comparison on the UUIDs contained in two Guid objects.
    /// Comparison is by value and not by reference.
    bool operator ==(other) {
      return this.value.toLowerCase() == other.toString().toLowerCase();
    }
  
    /// Returns the hashCode.
    @override
    int get hashCode {
      return super.hashCode;
    }
  
    /// Gets the UUID value contained by the Guid object as a string.
    @override
    String toString() {
      return value;
    }
  }
  
  class FlutterGuidError extends Error {
    final String message;
  
    FlutterGuidError(this.message);
  }
  
  </code></pre>
  <pre><code>Could not generate `fromJson` code for `colonizedStellarObjectId`.
  To support the type `Guid` you can:
  * Use `JsonConverter`
    https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html
  * Use `JsonKey` fields `fromJson` and `toJson`
    https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html
    https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html
  package:astrogame_app/models/stellar/base_types/colonizable_stellar_object.dart:14:14
     ╷
  14 │   late Guid? colonizedStellarObjectId;
     │              ^^^^^^^^^^^^^^^^^^^^^^^^
     ╵
  </code></pre>
  <p>I have written a converter for the json serialization:</p>
  <pre class="lang-dart prettyprint-override"><code>class GuidConverter implements JsonConverter&lt;Guid, String&gt; {
    const GuidConverter();
  
    @override
    Guid fromJson(String json) {
      return Guid(json);
    }
  
    @override
    String toJson(Guid object) {
      return object.toString();
    }
  }
  </code></pre>
  <p>When I set the property as not-null, everything is fine. What am I missing here?</p>