Skip to content

Enable the avoid_final_parameters lint.#185216

Merged
kallentu merged 7 commits into
flutter:masterfrom
kallentu:primary-constructor-final
Apr 28, 2026
Merged

Enable the avoid_final_parameters lint.#185216
kallentu merged 7 commits into
flutter:masterfrom
kallentu:primary-constructor-final

Conversation

@kallentu
Copy link
Copy Markdown
Contributor

@kallentu kallentu commented Apr 17, 2026

avoid_final_parameters lint fires when using a final modifier in any parameter list. This is a preparatory lint that helps us migrate to Dart 3.13. All violations from this lint will become compile-time errors in Dart 3.13 when the primary constructors feature ships.

Fixes: dart-lang/sdk#62590

Related to breaking changes: There should be nothing that breaks from adding this lint. Function types with final are already a compile-time error and any customers overriding a method with a final parameter won't break their code.

// Framework code
class C {
  void m(int x) { ... } // Removed var here.
}
// ...

// User code
class B implements C {
  void m(final int x) { ... } // Will still work.
}

This change should be test exempt.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. d: examples Sample code and demos platform-web Web applications specifically labels Apr 17, 2026
@kallentu kallentu added the CICD Run CI/CD label Apr 17, 2026
@github-actions github-actions Bot added platform-windows Building on or for Windows specifically a: desktop Running on desktop team-windows Owned by the Windows platform team and removed CICD Run CI/CD labels Apr 17, 2026
@kallentu kallentu added the CICD Run CI/CD label Apr 17, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 17, 2026
@kallentu kallentu added the CICD Run CI/CD label Apr 17, 2026
@kallentu kallentu force-pushed the primary-constructor-final branch from c32365c to 49777b0 Compare April 20, 2026 17:59
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 20, 2026
@kallentu kallentu added the CICD Run CI/CD label Apr 20, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 20, 2026
@kallentu kallentu added the CICD Run CI/CD label Apr 20, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 21, 2026
@kallentu kallentu added the CICD Run CI/CD label Apr 21, 2026
@kallentu kallentu changed the title Enable the avoid_final_parameters lint. Enable the avoid_final_parameters lint. Apr 21, 2026
Copy link
Copy Markdown
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

FYI I have speculatively opened a PR to enable the parameter_assignments lint: #185557

Copy link
Copy Markdown
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we can override the code freeze for this one. 👍

@Piinks Piinks added override code freeze Override an active code freeze. CICD Run CI/CD and removed CICD Run CI/CD labels Apr 27, 2026
@fluttergithubbot
Copy link
Copy Markdown
Contributor

An existing Git SHA, fbcf8d5d30ed31e799f7a719e2a5ac0eb74c4404, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@kallentu kallentu enabled auto-merge April 27, 2026 20:26
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 27, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 28, 2026
@kallentu kallentu added this pull request to the merge queue Apr 28, 2026
Copy link
Copy Markdown
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flutteractionsbot
Copy link
Copy Markdown
Contributor

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

auto-submit Bot pushed a commit that referenced this pull request May 7, 2026
auto-submit Bot pushed a commit that referenced this pull request May 8, 2026
#186270)

Reverts #186199. These lint changes aren't necessary for the intended dart version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: animation Animation APIs a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch d: examples Sample code and demos engine flutter/engine related. See also e: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. override code freeze Override an active code freeze. platform-web Web applications specifically platform-windows Building on or for Windows specifically team-framework Owned by Framework team team-windows Owned by the Windows platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Primary Constructors] Pre-release migrations

7 participants