Skip to content

[Bug] Code Generation Attempt Unintendedly Triggered #1303

@jlambright

Description

@jlambright

Given the abstract class (as well as a mixin version of the code) any sub-classes seem to trigger code generation attempts. However, I'm creating a wrapper class that consumes Built generated classes. This seems like buggy behavior. Either that, or it highlights the need for some kind of @built_ignore() annotation.

abstract class BuiltJsonSerializable<T extends Built<T, V>,
    V extends Builder<T, V>> {
  Serializer<T> get serializer;

  Map<String, dynamic> toJsonMap() => jsonDecode(toJsonString());

  String toJsonString() => standardSerializers.toJson<T>(serializer, toModel());

  T? toModel();

  T? modelFromJsonString(String serialized) {
    try {
      T? model = standardSerializers.fromJson<T>(serializer, serialized);
      return model;
    } on DeserializationError catch (e) {
      Get.log('[${T.toString()} DESERIALIZATION ERROR] ${e.toString()}');
      return null;
    }
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions