Skip to content

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

@matanlurey

Description

@matanlurey

Today, Flutter has a globally-scoped1 list of enabled feature flags, utilized by flutter config:

flutter config --enable-swift-package-manager

Swift Package Manager work has needed package-by-package opt-in/out support, implementing a 1-off:

It's come up with discussions with various teams (I certainly felt this with explicit-package-dependencies) that there is a good user (end-user) and developer (contributor to Flutter) need to be able to enable or disable these feature flags on a per-project basis:

flutter:
  # Could also be called "flags", just using existing terminology for now.
  config:
    swift-package-manager: true
    explicit-package-dependencies: false

I'd like to propose the following:

  1. We generalize the work done for disable-swift-package-manager (see above) or
  2. We implement something with similar capabilities

My thoughts on the V1 specification:

A feature flag can be used to conditionally allow or disallow some set of functionality in the Flutter tool, which in turn could be used to inform how _other_ tools (such as Gradle, Xcode) or runtimes (such as the Flutter framework, engine, Impeller) behave or what capabilities they support.

Feature flags are derived from one of two locations:

1. The currently executing app (where a `flutter` command is being run)'s `pubspec.yaml` _or_
2. Globally, as specified by `flutter config --enable-x` (or `flutter config --disable-x`)

Feature flags that are defined in an app's `pubspec.yaml` take precedence. 

Feature flags only support simple boolean (`true` or `false`) values, which default based on the
current channel being used (`master`, `beta`, or stable`), which matches the current implementation
done in [`flutter_tools/lib/src/features.dart`][1].

[1]: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/features.dart#L51-L55

/cc @Piinks @justinmc @jtmcdole

Footnotes

  1. Well, to the %HOME directory.

Metadata

Metadata

Labels

c: proposalA detailed proposal for a change to Flutterteam-toolOwned by Flutter Tool team

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions