Skip to content

Handle missing constructor more cleanly #79

Closed
@kevmoo

Description

@kevmoo

Input

@JsonSerializable()
class TestDoneEvent extends Object
    with _$TestDoneEventSerializerMixin  {
  @override
  final int time;

  @override
  String get type => "testDone";

  // The ID of the test that completed.
  final int testID;

  // The result of the test.
  final String result;

  // Whether the test's result should be hidden.
  final bool hidden;


  factory TestDoneEvent.fromJson(Map<String, dynamic> json) =>
      _$TestDoneEventFromJson(json);

}

error

  LibraryGenerationResultKind.noChange
    The null object does not have a getter 'parameters'.

    NoSuchMethodError: method not found: 'parameters'
    Receiver: null
    Arguments: []
    #0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
    #1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
    #2      _writeFactory (package:source_gen/generators/json_serializable_generator.dart:104:24)
    #3      JsonSerializableGenerator.generateForAnnotatedElement.<generateForAnnotatedElement_async_body> (package:source_gen/generators/json_serializable_generator.dart:50:20)
    #4      Future.Future.microtask.<anonymous closure> (dart:async/future.dart:144)
    #5      _microtaskLoop (dart:async/schedule_microtask.dart:41)
    #6      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
    #7      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
    #8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions