Skip to content

Support new constructor syntax. - #1400

Merged
davidmorgan merged 1 commit into
google:masterfrom
davidmorgan:primary-constructors
Sep 2, 2026
Merged

davidmorgan merged 1 commit into
google:masterfrom
davidmorgan:primary-constructors

Conversation

@davidmorgan

@davidmorgan davidmorgan commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Reject primary constructors cleanly; we can look at adding support for them properly as a bigger feature.

@davidmorgan
davidmorgan force-pushed the primary-constructors branch 2 times, most recently from e66d035 to 3c415fd Compare August 27, 2026 15:17
@davidmorgan davidmorgan changed the title Support primary constructors. Support new constructor syntax. Sep 1, 2026
@davidmorgan
davidmorgan marked this pull request as ready for review September 1, 2026 10:34
@davidmorgan

Copy link
Copy Markdown
Collaborator Author

@donny-dont I think this is ready now--please take a look and see if it does what you need :)

@vanyasem

vanyasem commented Sep 1, 2026 •

Copy link
Copy Markdown

I can confirm that this fixes my issue with with new constructors. built_value no longer throws an error, and generates cleanly
Tested on both BuiltValue and EnumClass

@donny-dont

Copy link
Copy Markdown
Contributor

@donny-dont I think this is ready now--please take a look and see if it does what you need :)

I just added the following lint rules

    - empty_container_bodies
    - initialize_in_field_declaration
    - unnecessary_const_in_enum_constructor
    - unnecessary_primary_constructor_body
    - unnecessary_type_name_in_constructor
    - use_declaring_parameters

Applied them through dart fix --apply . and then ran dart run build_runner build successfully so this is good to go.

Thanks @davidmorgan !

@davidmorgan
davidmorgan merged commit 5ad3664 into google:master Sep 2, 2026
7 checks passed
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.

3 participants