forked from firka/flutter
[flutter_tools] wire up alternative invalidation strategy to features (#70865)
This commit is contained in:
@@ -49,6 +49,9 @@ abstract class FeatureFlags {
|
||||
/// Whether fast single widget reloads are enabled.
|
||||
bool get isSingleWidgetReloadEnabled => false;
|
||||
|
||||
/// Whether the CFE experimental invalidation strategy is enabled.
|
||||
bool get isExperimentalInvalidationStrategyEnabled => false;
|
||||
|
||||
/// Whether a particular feature is enabled for the current channel.
|
||||
///
|
||||
/// Prefer using one of the specific getters above instead of this API.
|
||||
@@ -92,6 +95,9 @@ class FlutterFeatureFlags implements FeatureFlags {
|
||||
@override
|
||||
bool get isSingleWidgetReloadEnabled => isEnabled(singleWidgetReload);
|
||||
|
||||
@override
|
||||
bool get isExperimentalInvalidationStrategyEnabled => isEnabled(experimentalInvalidationStrategy);
|
||||
|
||||
@override
|
||||
bool isEnabled(Feature feature) {
|
||||
final String currentChannel = _flutterVersion.channel;
|
||||
@@ -125,6 +131,7 @@ const List<Feature> allFeatures = <Feature>[
|
||||
flutterAndroidFeature,
|
||||
flutterIOSFeature,
|
||||
flutterFuchsiaFeature,
|
||||
experimentalInvalidationStrategy,
|
||||
];
|
||||
|
||||
/// The [Feature] for flutter web.
|
||||
@@ -270,6 +277,29 @@ const Feature singleWidgetReload = Feature(
|
||||
),
|
||||
);
|
||||
|
||||
/// The CFE experimental invalidation strategy.
|
||||
const Feature experimentalInvalidationStrategy = Feature(
|
||||
name: 'Hot reload optimization that reduces incremental artifact size',
|
||||
configSetting: 'experimental-invalidation-strategy',
|
||||
environmentOverride: 'FLUTTER_CFE_EXPERIMENTAL_INVALIDATION',
|
||||
master: FeatureChannelSetting(
|
||||
available: true,
|
||||
enabledByDefault: true,
|
||||
),
|
||||
dev: FeatureChannelSetting(
|
||||
available: true,
|
||||
enabledByDefault: false,
|
||||
),
|
||||
beta: FeatureChannelSetting(
|
||||
available: true,
|
||||
enabledByDefault: false,
|
||||
),
|
||||
stable: FeatureChannelSetting(
|
||||
available: true,
|
||||
enabledByDefault: false,
|
||||
),
|
||||
);
|
||||
|
||||
/// A [Feature] is a process for conditionally enabling tool features.
|
||||
///
|
||||
/// All settings are optional, and if not provided will generally default to
|
||||
|
||||
@@ -139,12 +139,13 @@ class FlutterDevice {
|
||||
} else {
|
||||
// The flutter-widget-cache feature only applies to run mode.
|
||||
List<String> extraFrontEndOptions = buildInfo.extraFrontEndOptions;
|
||||
if (featureFlags.isSingleWidgetReloadEnabled) {
|
||||
extraFrontEndOptions = <String>[
|
||||
'--flutter-widget-cache',
|
||||
...?extraFrontEndOptions,
|
||||
];
|
||||
}
|
||||
extraFrontEndOptions = <String>[
|
||||
if (featureFlags.isSingleWidgetReloadEnabled)
|
||||
'--flutter-widget-cache',
|
||||
if (featureFlags.isExperimentalInvalidationStrategyEnabled)
|
||||
'--enable-experiment=alternative-invalidation-strategy',
|
||||
...?extraFrontEndOptions,
|
||||
];
|
||||
generator = ResidentCompiler(
|
||||
globals.artifacts.getArtifactPath(
|
||||
Artifact.flutterPatchedSdkPath,
|
||||
|
||||
Reference in New Issue
Block a user