Skip to content

🔥[Urgent] Fix Model Generation Error, Update Parsing for int and double to num #283

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

knottx
Copy link
Contributor

@knottx knottx commented Oct 9, 2024

  1. Fixed an error encountered during the model generation process.

  2. Changed the parsing logic to handle int and double values by converting them to num. This ensures better compatibility and flexibility in handling numeric values.

Why Use num Instead of int and double?

  • Flexibility: The num type is a superclass of both int and double, allowing a variable of type num to hold either integer or floating-point values. This flexibility simplifies the code and reduces the need for type checks or conversions when dealing with numbers that may vary in type.
  • Ease of Handling Mixed Numeric Values: In scenarios where calculations or data parsing may involve both integers and doubles, using num can help avoid runtime exceptions that might occur from type mismatches. For example, when summing or averaging values of different types, num will seamlessly accommodate both without additional type conversion logic.
  • Cleaner Code: Utilizing num can lead to cleaner and more concise code. Instead of writing separate logic for handling int and double, you can work with a unified numeric type, which simplifies the implementation and reduces boilerplate code.
  • Improved Compatibility: When interfacing with APIs or databases that return numeric values, the response might not consistently be of a single type. Using num allows the code to handle these variations gracefully, enhancing compatibility and reducing the likelihood of errors during data processing.

https://dart.dev/guides/language/numbers

For people who are waiting for this
you can use my repository for now

dart pub global deactivate get_cli

dart pub global activate -s git https://github.com/knottx/get_cli.git --git-ref fix-generate-model

@knottx knottx changed the title 🔥[Urgent] Fix Model Generation Error and Update Parsing for Int and Double 🔥[Urgent] Fix Model Generation Error and Update Parsing for int and double to num Oct 9, 2024
@knottx knottx changed the title 🔥[Urgent] Fix Model Generation Error and Update Parsing for int and double to num 🔥[Urgent] Fix Model Generation Erro, Update Parsing for int and double to num Oct 9, 2024
@knottx
Copy link
Contributor Author

knottx commented Oct 17, 2024

@jonataslaw

@whitecodel
Copy link

You can try this CLI tools for generating models

https://github.com/whitecodel/jsontodart

@knottx knottx changed the title 🔥[Urgent] Fix Model Generation Erro, Update Parsing for int and double to num 🔥[Urgent] Fix Model Generation Error, Update Parsing for int and double to num Feb 16, 2025
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