hiranthaR / Json-to-Dart-Model

Json to Dart Model extension can convert JSON objects into Dart data classes. It supports pure Dart class conversion, Flutter-recommended JSON serialization using annotations, Freezed support, Effective Dart:Style, and many more features. Currently, it has more than 135,000 installs.
https://marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
MIT License
93 stars 18 forks source link

Effective Dart style. #8

Closed iamarnas closed 3 years ago

iamarnas commented 3 years ago

Describe the bug Would it be possible follow effective dart style guides.

Screenshots Skärmavbild 2020-12-22 kl  14 26 53

Version version: 2.4.1

hiranthaR commented 3 years ago

I'll try to manage my time for this. thank you for the suggestion

iamarnas commented 3 years ago

@hiranthaR Hi again.

I found one bug to. Most of API providers use word get in their json files you can see in my bild example. And when your extension generate code his create String value with name get which is reserved by system. I recommend to regenerate this to example: class Products {} generate String getProtucts instead String get.

From my picture it would be value String getTimezone

Screenshot_20201222_151709_org.mozilla.firefox.png

iamarnas commented 3 years ago

@hiranthaR Hi, I have updated your app syntax.ts file and you can see how was before and after update.

Before:

Skärmavbild 2020-12-27 kl  17 47 30

After:

Skärmavbild 2020-12-27 kl  17 43 51

And now all generated files by your extension is full supported Effective Dart: Style and friendly with expert developers :)

No more List<Null> warning or (empty list error) and all reserved values by system are regenerated automatically. You can see in the example what it looks like. Planning add automatic identification of DateTime from the String and copyWith(); Function.

iamarnas commented 3 years ago

Today added copyWith(); method. User can choose before generating files :)

Skärmavbild 2020-12-27 kl  19 32 35

hiranthaR commented 3 years ago

@iamarnas hi, I fixed others without copyWith function. I'll do it another day. can you check your requirements are satisfied?

iamarnas commented 3 years ago

@hiranthaR Nice, I'll do it. I did not expect you to fix it so quickly. That's why I updated your extension it myself :) If you are interested I can share to you my changes. I have advanced syntax formatting it detect when needs expression function or block function very correct to dartfmt. And planning to add for to ask user if he want use immutable classes or not. Because for now only with Equatable creates immutable classes. It should be more flexible.

hiranthaR commented 3 years ago

@iamarnas oh sorry. I didn't know that. sure open a PR. I'll revert my commits and publish yours. It's totally fine.

iamarnas commented 3 years ago

@hiranthaR Hi, Here is your result after new update :)

Skärmavbild 2020-12-28 kl  23 57 26

remove const from the constructor for now. It's not immutable class and it will show lint error for all created classes. That why I want add function to ask users if they want use @immutable classes. Leave me to fix all Dart languages guide lines becouse im pedantic Dart user ;)

hiranthaR commented 3 years ago

I think we are better to go with your changes

iamarnas commented 3 years ago

@hiranthaR Hi. Opened a PR. Just needs update the readme-file after new changes. And here your English is better than mine :)

iamarnas commented 3 years ago

How it looks syntax after update. carbon(1) carbon