Skip to content

Conversation

matanlurey
Copy link
Contributor

Closes #167667.

In this PR:

  • FlutterFeaturesConfig reads from the global config, current pubspec.yaml, and environment
  • FeatureFlags now delegates "was this configured" to FlutterFeaturesConfig
  • featureFlags (Context) now is created with knowledge of the current pubpec.yaml, if any

Once this lands and we play with it a bit (i.e. migrate disable-swift-package-manager), we can publicize it and update website documentation (it won't make it into this beta/stable release anyway).

I did a significant rewrite of feature_test, as lots of what was being tested no longer made sense.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 28, 2025
Comment on lines 39 to 42
/// The value is resolved, if possible, in the following order, where if a
/// step resolves to a boolean value, no further steps are attempted.
///
/// ## Environment Variable
Copy link
Member

Choose a reason for hiding this comment

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

Consider making it clearer this is an ordered list:

Suggested change
/// The value is resolved, if possible, in the following order, where if a
/// step resolves to a boolean value, no further steps are attempted.
///
/// ## Environment Variable
/// The value is resolved, if possible, in the following order, where if a
/// step resolves to a boolean value, no further steps are attempted:
///
/// ## 1. Environment Variable

/// The value is resolved, if possible, in the following order, where if a
/// step resolves to a boolean value, no further steps are attempted.
///
/// ## Environment Variable
Copy link
Member

Choose a reason for hiding this comment

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

In the current implementation, the environment variable has lower priority than the global config. Could we keep that order and make the local project configuration the highest priority?

///
/// [globalConfig] reads values stored by the `flutter config` tool, which
/// are normally in the user's `%HOME` directory (varies by system), while
/// [projectManfiest] reads values from the _current_ Flutter project's
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// [projectManfiest] reads values from the _current_ Flutter project's
/// [projectManifest] reads values from the _current_ Flutter project's

expect(
flutterMacOSDesktopFeature.generateHelpMessage(),
'Enable or disable support for desktop on macOS.',
testWithoutContext('reads from configuration if avaialble', () {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
testWithoutContext('reads from configuration if avaialble', () {
testWithoutContext('reads from configuration if available', () {

@@ -254,6 +254,8 @@ void main() {
containsIgnoringWhitespace('Analytics reporting is currently enabled'),
);
}, overrides: <Type, Generator>{Analytics: () => fakeAnalytics});

testUsingContext('overriden by the content in pubspec.yaml', () async {});
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this can be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

Looks good overall, one open question on ordering

@matanlurey
Copy link
Contributor Author

Thanks for the review! Will come back to this shortly, agree on changes.

Copy link
Contributor

@bkonyi bkonyi left a comment

Choose a reason for hiding this comment

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

LGTM once @loic-sharma's comments are addressed.

});
}

const Feature _noConfigFeature = Feature(name: 'example');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ubernit: should these constants be top of file for readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

});

/// Flutter Web
FileSystem createFsWithPubspec(String pubspec) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Since we're only using this in one place, can we instead hardcode the contents of pubspec here and not take a parameter? That way it's obvious what the contents of the pubspec are without scrolling to the bottom of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Apr 28, 2025
Merged via the queue into flutter:master with commit f94a82d Apr 29, 2025
143 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 29, 2025
}
return isEnabled;

// Otherwise, read it from environment variable > project manifest > global config
Copy link
Member

Choose a reason for hiding this comment

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

FYI this comment is stale

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
mg3994 added a commit to mg3994/website that referenced this pull request May 22, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
…FeatureFlags` (flutter#167953)

Closes flutter#167667.

In this PR:

- `FlutterFeaturesConfig` reads from the global config, current
pubspec.yaml, and environment
- `FeatureFlags` now delegates "was this configured" to
`FlutterFeaturesConfig`
- `featureFlags` (`Context`) now is created with knowledge of the
current `pubpec.yaml`, if any

Once this lands and we play with it a bit (i.e. migrate
`disable-swift-package-manager`), we can publicize it and update website
documentation (it won't make it into this beta/stable release anyway).

I did a significant rewrite of `feature_test`, as lots of what was being
tested no longer made sense.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: flutter config flags can be specified in an app's pubspec.yaml
3 participants