You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Primary constructors require a recent Dart SDK, so changing the default output could break generated code for projects using older Dart versions.
Making this an opt-in renderer option would preserve backwards compatibility while allowing projects using modern Dart to take advantage of the newer syntax.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hi!
Context
Dart 3.13 introduced primary constructors, allowing constructor parameters and fields to be declared directly as part of the class declaration.
Quicktype currently generates Dart models using traditional field declarations and constructors.
For example:
With Dart's primary constructor syntax, this can now be expressed more concisely:
Proposal
It would be useful for the Dart renderer to optionally generate models using primary constructors.
For example, a CLI option such as:
Could generate:
Instead of:
Why make it optional?
Primary constructors require a recent Dart SDK, so changing the default output could break generated code for projects using older Dart versions.
Making this an opt-in renderer option would preserve backwards compatibility while allowing projects using modern Dart to take advantage of the newer syntax.
All reactions