Skip to content

[BUG] @JsonDefault gera código Dart inválido para tipos int e double #156

@Maxwell-Alexander-Volus

Description

🐛 Bug Report

📄 Title

Describe the bug briefly and clearly.

🔗 External Link

Insert the bug link in the bug management platform

🖥️ Environment

  • Operating System: Windows 11
  • Application Version: vaden 1.0.2
  • Dart: 3.11.1

📝 Detailed Description

Ao usar a anotação @JsonDefault com tipos int ou double,
o build_runner gera código Dart inválido usando int() e double()
como construtores, que não existem no Dart.

🔄 Steps to Reproduce

  1. Criar um DTO com @JsonDefault em campos int ou double
  2. Executar dart run build_runner build
  3. Verificar o arquivo gerado vaden_application.dart

Code

@dto()
class CreateEarningRequest {
@jsonkey('month_id')
final int monthId;

@JsonDefault('SALARIO')
final String name;

@jsonkey('gross_value')
@JsonDefault(1000.0)
final double grossValue;

@jsonkey('net_value')
@JsonDefault(800.0)
final double netValue;

@jsonkey('earning_date')
@JsonDefault('2026-03-05')
final String earningDate;

CreateEarningRequest({
required this.monthId,
required this.name,
required this.grossValue,
required this.netValue,
required this.earningDate,
});
}

Expected Result

#monthId: json.containsKey('month_id') ? json['month_id'] : 0,
#grossValue: json.containsKey('gross_value') ? json['gross_value'] : 6200.0,

Actual Result

#monthId: json.containsKey('month_id') ? json['month_id'] : int(0),
#grossValue: json.containsKey('gross_value') ? json['gross_value'] : double(6200.0),

📷 Evidence

Add relevant screenshots, videos, or logs.

⚠️ Severity

  • Low
  • Medium
  • High
  • Critical

🚨 Priority

  • P1 (High)
  • P2 (Medium)
  • P3 (Low)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions