Skip to content

feat: Add support for double default values #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ikku47
Copy link

@ikku47 ikku47 commented Jun 30, 2025

🐛 Problem

When using the "set default values" option, double fields were not getting default values assigned, causing inconsistent behavior compared to other primitive types (int, bool, String, List).

This could lead to:

  • Runtime issues in Dart when double fields are not nullable
  • Inconsistent code generation
  • Missing default values for double properties

✅ Solution

Added complete support for double default values across the entire codebase:

Changes Made:

  1. Settings.kt:

    • Added doubleDefaultValue: String = "0.0" field
    • Added doubleFieldDefaultValue(): String? method
  2. ClassDefinition.kt:

    • Added double case in field generation logic
    • Bonus fix: Fixed existing bugs where bool and int checks incorrectly used stringFieldDefaultValue()
  3. JsonInputDialog.kt:

    • Added UI input field for double default values
    • Positioned logically between int and bool fields

🧪 Testing

  • All files compile without errors
  • UI properly displays double default value input field
  • Generated code includes double default values when enabled
  • Existing functionality for other types remains unchanged

📸 Before vs After

Before: double fields had no default values
After: double fields get configurable default values (default: "0.0")

🔗 Related Issues

Fixes the missing double default value support identified during codebase analysis.

- Add doubleDefaultValue field and doubleFieldDefaultValue() method to Settings
- Add double case in ClassDefinition field generation logic
- Add UI input field for double default values in JsonInputDialog
- Fix existing bugs where bool/int checks used stringFieldDefaultValue()

Fixes issue where double fields didn't get default values when 'set default'
option was enabled, causing inconsistent behavior compared to other primitive types.
@ikku47 ikku47 requested a review from zhangruiyu as a code owner June 30, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants