Skip to content

Revert: [flutter_tools] forward --offline flag to pub.get in update-packages - #193808

Merged
cbracken merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-193619-1791170420
Oct 5, 2026
Merged

cbracken merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-193619-1791170420

Conversation

@flutteractionsbot

Copy link
Copy Markdown
Contributor

Reverts: [flutter_tools] forward --offline flag to pub.get in update-packages

Initiated by: @cbracken

Reason for reverting: info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart:315:24 • prefer_const_constructors

Original PR Author: @bkonyi

Reviewed By: @chingjun

The original PR description is provided below:

When running flutter update-packages --offline, the --offline flag was parsed and used to validate incompatible option combinations (such as --force-upgrade and --cherry-pick-package), but was not forwarded to the underlying pub.get invocations. Forward offline through _pubGet to pub.get so that pub does not attempt network operations in offline environments.

Fixes #193423

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 5, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 5, 2026

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

Copy link
Copy Markdown
Contributor

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 simplifies the _pubGet helper method in UpdatePackagesCommand by removing the offline parameter and converting enforceLockfile into a positional boolean parameter. It also removes the corresponding offline-related tests and mock tracking. Feedback suggests reverting the change of enforceLockfile to a positional boolean parameter, recommending named arguments instead to maintain readability at call sites in accordance with Dart style guidelines.

Comment on lines +246 to +259
await _pubGet(rootProject, !forceUpgrade && cherryPicks.isEmpty && !updateHashes);

// Manually do a pub get for packages not part of the workspace.
// See https://github.com/flutter/flutter/pull/170364.
await _pubGet(toolProject, enforceLockfile: false, offline: offline);
await _pubGet(
FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory),
enforceLockfile: false,
offline: offline,
);
await _pubGet(toolProject, false);
await _pubGet(FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory), false);

await _downloadCoverageData();

return FlutterCommandResult.success();
}

Future<void> _pubGet(
FlutterProject project, {
required bool enforceLockfile,
required bool offline,
}) async => pub.get(
context: PubContext.pubGet,
project: project,
enforceLockfile: enforceLockfile,
offline: offline,
);
Future<void> _pubGet(FlutterProject project, bool enforceLockfile) async =>
pub.get(context: PubContext.pubGet, project: project, enforceLockfile: enforceLockfile);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a positional boolean parameter (bool enforceLockfile) makes the call sites less readable and harder to understand at a glance (e.g., _pubGet(toolProject, false)). Following the Dart style guidelines, it is highly recommended to use named arguments for boolean parameters to improve code clarity and maintainability.

    await _pubGet(
      rootProject,
      enforceLockfile: !forceUpgrade && cherryPicks.isEmpty && !updateHashes,
    );

    // Manually do a pub get for packages not part of the workspace.
    // See https://github.com/flutter/flutter/pull/170364.
    await _pubGet(toolProject, enforceLockfile: false);
    await _pubGet(
      FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory),
      enforceLockfile: false,
    );

    await _downloadCoverageData();

    return FlutterCommandResult.success();
  }

  Future<void> _pubGet(
    FlutterProject project, {
    required bool enforceLockfile,
  }) async => pub.get(
    context: PubContext.pubGet,
    project: project,
    enforceLockfile: enforceLockfile,
  );
References
  1. Effective Dart recommends using named arguments for boolean parameters to improve readability at call sites. (link)

@cbracken cbracken added the emergency Jump the queue; land PR in front of all others; only use for emergencies label Oct 5, 2026
@flutter-dashboard

Copy link
Copy Markdown

Detected the emergency label.

If you add the autosubmit label, the bot will wait until all presubmits pass but ignore the tree status, allowing fixes for tree breakages while still validating that they don't break any existing presubmits.

The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue".

@cbracken
cbracken added this pull request to the merge queue Oct 5, 2026
Merged via the queue into flutter:master with commit 4f1d340 Oct 5, 2026
27 of 28 checks passed
@flutteractionsbot
flutteractionsbot deleted the revert-193619-1791170420 branch October 5, 2026 04:25
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-flutter__flutter that referenced this pull request Oct 23, 2026
…ackages" (flutter#193838)

Relands flutter#193619 (reverted in
flutter#193808) with `const` added to
`DelegatingToolContext()` in `update_packages_test.dart` to satisfy
`prefer_const_constructors`.

When running `flutter update-packages --offline`, the `--offline` flag
was parsed and used to validate incompatible option combinations (such
as `--force-upgrade` and `--cherry-pick-package`), but was not forwarded
to the underlying `pub.get` invocations. Read `boolArg(_keyOffline)` in
`_pubGet` and forward it to `pub.get` so that `pub` does not attempt
network operations in offline environments.

Fixes flutter#193423

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]: https://flutter.dev/to/breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…ackages (flutter#193808)

Reverts: [[flutter_tools] forward --offline flag to pub.get in
update-packages](flutter#193619)

Initiated by: @cbracken

Reason for reverting: info • Use 'const' with the constructor to improve
performance. Try adding the 'const' keyword to the constructor
invocation •
packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart:315:24
• prefer_const_constructors

Original PR Author: @bkonyi

Reviewed By: @chingjun

The original PR description is provided below:

When running `flutter update-packages --offline`, the `--offline` flag
was parsed and used to validate incompatible option combinations (such
as `--force-upgrade` and `--cherry-pick-package`), but was not forwarded
to the underlying `pub.get` invocations. Forward `offline` through
`_pubGet` to `pub.get` so that `pub` does not attempt network operations
in offline environments.

Fixes flutter#193423

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…ackages" (flutter#193838)

Relands flutter#193619 (reverted in
flutter#193808) with `const` added to
`DelegatingToolContext()` in `update_packages_test.dart` to satisfy
`prefer_const_constructors`.

When running `flutter update-packages --offline`, the `--offline` flag
was parsed and used to validate incompatible option combinations (such
as `--force-upgrade` and `--cherry-pick-package`), but was not forwarded
to the underlying `pub.get` invocations. Read `boolArg(_keyOffline)` in
`_pubGet` and forward it to `pub.get` so that `pub` does not attempt
network operations in offline environments.

Fixes flutter#193423

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]: https://flutter.dev/to/breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD emergency Jump the queue; land PR in front of all others; only use for emergencies tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter update-packages --offline does not pass --offline to pub

2 participants