Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g commented Nov 24, 2025

Makes the analysis options changes described in flutter/flutter#178827:

After those changes, makes the following repo-wide changes:

  • dart fix --apply in all packages and in script/tool/
  • dart format in all packages and in script/tool/
  • update-excerpts repo tooling command to update excerpts based on the changes to their sources

Also updates the min Flutter/Dart SDK version to 3.35/3.9 for the following packages, to avoid analyze failures in the N-2 legacy analysis run due to what appears to be a 3.9 change in what the Dart analyzer continues to be an obvious local type in loop iterations:

  • go_router
  • google_fonts
  • google_identity_services_web
  • google_maps_flutter_web
  • local_auth_platform_interface
  • metrics_center
  • multicast_dns
  • pigeon
  • rfw
  • shared_preferences
  • two_dimensional_scrollables
  • vector_graphics_compiler
  • mustache_template
  • path_parsing

Because this is causing a significant amount of format churn already, I took this opportunity to update the repository tooling to a min Dart SDK of 3.8 (the N-2 stable version, so the earliest version we need the tooling to support) to pick up the new format style, so the amount of automated formatter change is higher in script/tool/ than in the packages.

This does contain two manual changes (other than the repo tooling min version):

  • d700b45 changes dynamic to Object? in a few places where dynamic caused analyzer warnings under the new rule set.
  • Updates the repo tooling to ignore .dart_tool/ when looking for unexpected local analysis_options.yaml files, to fix issues running the repo tool's analyze command locally based on recent changes in dart behavior.

This does not include any CHANGELOG or version updates; even though we normally version any changes to production code, mass automated changes like this aren't worth the churn of releasing. This includes changes to lib/example/main.dart and to README.md excerpts; while the style changes will be user-visible on pub.dev, it's fine for those changes to wait for the next release of each package.

Part of flutter/flutter#178827

@github-actions github-actions bot added p: google_fonts triage-framework Should be looked at in framework triage triage-engine Should be looked at in engine triage p: google_identity_services p: mustache_template labels Nov 24, 2025
@stuartmorgan-g
Copy link
Collaborator Author

@tarrinneal or @bparrishMines please review the non-automated commits (3620b2c, f231a2f, d700b45).

Everyone else, please feel free to ignore this PR.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new linter rules to prefer type inference for obvious local variables and then applies these changes across the entire repository. The changes are extensive but mostly automated, resulting in more concise code by removing explicit type annotations where they are redundant. The modifications to analysis_options.yaml are correct and the subsequent code fixes align with the new linting rules. Overall, this is a solid stylistic improvement for the codebase.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM for go_router and go_router_builder part

@stuartmorgan-g
Copy link
Collaborator Author

Hm, that's unfortunate. From the analyze_legacy N-2 failures it appears that what the analyzer considers a non-obvious local in the context of a list iteration changed in Dart 3.9. I'm going to update all the affected packages to a min of Dart 3.9 to avoid the issue.

@Piinks
Copy link
Contributor

Piinks commented Nov 24, 2025

Hm, that's unfortunate. From the analyze_legacy N-2 failures it appears that what the analyzer considers a non-obvious local in the context of a list iteration changed in Dart 3.9. I'm going to update all the affected packages to a min of Dart 3.9 to avoid the issue.

Ah good to know! I will bump the framework too, I think it is still on 3.8

@Piinks
Copy link
Contributor

Piinks commented Nov 24, 2025

.. or 3.10. We're headed that way to adopt dot shorthands in the framework. Checking in with @loic-sharma

@stuartmorgan-g
Copy link
Collaborator Author

Ah good to know! I will bump the framework too, I think it is still on 3.8

I would not expect this issue to affect anything in the framework tree; it's specific to the fact that we run analyze with Flutter master, stable, N-1 stable, and N-2 stable. Presumably flutter/flutter is only running analyze with its own current version of dart.

@Piinks
Copy link
Contributor

Piinks commented Nov 24, 2025

Ok. Touched base with Loïc, we want to publish guidelines/style guide for use of dot shorthands, so we won't bump to 3.10 until we have been able to finalize and communicate those.

Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

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

package:mustache_template changes look good to me! Thanks :D

@Piinks
Copy link
Contributor

Piinks commented Nov 24, 2025

Oh so nice! 👏
image

Copy link
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

@stuartmorgan-g
Copy link
Collaborator Author

Since there's a window of opportunity here where everything passed without any other PRs landing (and since unlike flutter/flutter we don't have a way to close the flutter/packages tree manually), I'm going to seize the moment and land this now rather than tomorrow.

@stuartmorgan-g stuartmorgan-g merged commit cc3dca6 into flutter:main Nov 24, 2025
81 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 25, 2025
agrapine pushed a commit to swipelab/flutter_packages that referenced this pull request Nov 26, 2025
Makes the analysis options changes described in
flutter/flutter#178827:
- Adding
[omit_obvious_local_variable_types](https://dart.dev/tools/linter-rules/omit_obvious_local_variable_types)
- Adding
[specify_nonobvious_local_variable_types](https://dart.dev/tools/linter-rules/specify_nonobvious_local_variable_types)
- Adding
[specify_nonobvious_property_types](https://dart.dev/tools/linter-rules/specify_nonobvious_property_types)
- Adding
[type_annotate_public_apis](https://dart.dev/tools/linter-rules/type_annotate_public_apis)
- Removing
[always_specify_types](https://dart.dev/tools/linter-rules/always_specify_types)

After those changes, makes the following repo-wide changes:
- `dart fix --apply` in all packages and in script/tool/
- `dart format` in all packages and in script/tool/
- `update-excerpts` repo tooling command to update excerpts based on the
changes to their sources

Also updates the min Flutter/Dart SDK version to 3.35/3.9 for the
following packages, to avoid `analyze` failures in the `N-2` legacy
analysis run due to what appears to be a 3.9 change in what the Dart
analyzer continues to be an obvious local type in loop iterations:
- go_router
- google_fonts
- google_identity_services_web
- google_maps_flutter_web
- local_auth_platform_interface
- metrics_center
- multicast_dns
- pigeon
- rfw
- shared_preferences
- two_dimensional_scrollables
- vector_graphics_compiler
- mustache_template
- path_parsing

Because this is causing a significant amount of format churn already, I
took this opportunity to update the repository tooling to a min Dart SDK
of 3.8 (the N-2 stable version, so the earliest version we need the
tooling to support) to pick up the new format style, so the amount of
automated formatter change is higher in script/tool/ than in the
packages.

This does contain two manual changes (other than the repo tooling min
version):
-
flutter@d700b45
changes `dynamic` to `Object?` in a few places where `dynamic` caused
analyzer warnings under the new rule set.
- Updates the repo tooling to ignore `.dart_tool/` when looking for
unexpected local `analysis_options.yaml` files, to fix issues running
the repo tool's `analyze` command locally based on recent changes in
`dart` behavior.

This does not include any CHANGELOG or version updates; even though we
normally version any changes to production code, mass automated changes
like this aren't worth the churn of releasing. This includes changes to
lib/example/main.dart and to README.md excerpts; while the style changes
will be user-visible on pub.dev, it's fine for those changes to wait for
the next release of each package.

Part of flutter/flutter#178827
@jesswrd jesswrd mentioned this pull request Nov 26, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants