Search code examples
flutterdartdart-pub

Unhandled exception: Unsupported operation: serialization of generic DartType: UnknownType(?) (UnknownType)


I keep getting this error

Unhandled exception: Unsupported operation: serialization of generic DartType: UnknownType(?) (UnknownType)

everytime i try to run my project. I run flutter packages pub run build_runner build and I get pub finished with exit code 78

/// Something was unconfigured or mis-configured. const CONFIG = 78;

This is likely because the.dart_tool/build folder was deleted, or you are submitting generated files to your source repository. [SEVERE] Conflicting outputs were detected and the build is unable to prompt for permission to remove them. These outputs must be removed manually or the build can be run with `--delete-conflicting-outputs

I then proceed to run flutter packages pub run build_runner build --delete-conflicting-outputs and get

[INFO] Succeeded after 49.5s with 14 outputs (227 actions)

and on runnning my app we I get the Dart compiler exited unexpectedly.


Solution

  • solved it by adding a build.yaml configs:

        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
              create_factory: true
              create_to_json: true
              disallow_unrecognized_keys: false
              explicit_to_json: false
              field_rename: none
              ignore_unannotated: false
              include_if_null: true
              nullable: true
    

    [INFO] Succeeded after 199ms with 0 outputs (0 actions)