Skip to content

Enable parameter_assignments lint #185704

Open

Description

@justinmc

Background

Flutter's code style has typically not enforced whether or not parameters can be modified in function bodies.

void greet(String name) {
  name = 'The Respectable $name'; // Is this ok? Styleguide and linter don't care.
  return 'Hello $name';
}

It has been possible to use final to enforce that a parameter can't be modified:

void greet(final String name) {
  name = 'The Respectable $name'; // Compilation error.
...

But recently, PR #185216 was landed that disallowed using final in this way (for good reasons, see the PR for details).

Proposal

I propose that Flutter should adopt the parameter_assignments lint, which would enforce that parameters cannot be modified.

void greet(String name) {
  // name = 'The Respectable $name'; // Lint error.
  final String nameWithTitle = 'The Respectable $name';
  return 'Hello $nameWithTitle';
}

In my opinion, having the ability to modify parameters increases the mental burden of understanding a function (e.g., "I want to use this parameter name, but has it been changed? I have to read through all previous lines of code in the function to be sure that it hasn't.").

This will have to be done in pieces due to the code freeze.

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    and removed
    in triagePresently being triaged by the triage team
    on Apr 29, 2026
  2. added
    P3Issues that are less important to the Flutter project
    on May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions