Skip to content
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

[REQ] [Dart] Don't initialize variables to null #3633

Closed
nickmeinhold opened this issue Aug 13, 2019 · 1 comment · Fixed by #6729
Closed

[REQ] [Dart] Don't initialize variables to null #3633

nickmeinhold opened this issue Aug 13, 2019 · 1 comment · Fixed by #6729

Comments

@nickmeinhold
Copy link
Contributor

nickmeinhold commented Aug 13, 2019

Is your feature request related to a problem? Please describe.

Models have their members initialized to null which is against the Effective Dart guidelines.

Describe the solution you'd like

When the default value is null, just declare the variable as in Dart, "a variable or field that is not explicitly initialized automatically gets initialized to null" and "Adding = null is redundant and unneeded."

Describe alternatives you've considered

I tried using an inverted section based on the defaultValue but it didn't work, I don't know mustache well enough yet but I'll come back to it.

Additional context

https://dart.dev/guides/language/effective-dart/usage#dont-explicitly-initialize-variables-to-null

@wing328
Copy link
Member

wing328 commented Aug 13, 2019

OK. I can take a look as I'm familiar with the default value.

agilob added a commit to agilob/openapi-generator that referenced this issue Jun 21, 2020
@agilob agilob mentioned this issue Jun 21, 2020
5 tasks
wing328 pushed a commit that referenced this issue Jul 23, 2020
* [Dart] Fix enum generation

* Update generated Order file

* Re-add constructor

* Generate dart2 files

* Dart - nicer enum formatting

* Dart - generate enum name as className+enumName

* Dart - dont initialize vars to null by default

Fixes #3633

* Dart - Generate inlined enums and deserialize them

* Merge branch 'master' of github.com:agilob/openapi-generator into 6727

* Dart - Fix using default value

* Fix typo

* Regenerate add dart files

* dart Revert override for dart dio and jaguar

* Fix dart model tests

* Fix dart1 generated template

* Use {{{datatypeWithEnum}}}

* Dart - throw when enum not known

* Fix generating enum with datatype from list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants