Skip to content

[bug] json_serializable cannot generate classes that inherit from LinkedListEntry #1512

@yiky84119

Description

@yiky84119

[bug] json_serializable cannot generate classes that inherit from LinkedListEntry

import 'dart:collection';

import 'package:json_annotation/json_annotation.dart';

part 'print_data.g.dart';

@JsonSerializable()
final class PrintData extends LinkedListEntry<PrintData>{
  
  String name;
  bool error;

  PrintData(this.name, {
    this.error = false
  });

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

  Map<String, dynamic> toJson() => _$PrintDataToJson(this);
}

json_serializable is trying to process the private _list variable from LinkedListEntry

PS C:\Users\Nevo> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.8, on Microsoft Windows [版本 10.0.26100.4770], locale zh-CN)
[✓] Windows Version (Windows 11 or higher, 24H2, 2009)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    ✗ cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure
      to set the ANDROID_HOME environment variable.
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/windows-android-setup for more details.
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.9 (July 2025))
[✓] Android Studio (version 2025.1.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2025.1)
[✓] Proxy Configuration
[✓] Connected device (3 available)
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions