Unverified Commit d22d65c6 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] add the feature for single widget reloads (#61411)

Implements the flutter config feature for #61407 , but does not implement any of the functionality.
parent 74f3e6dd
...@@ -34,6 +34,9 @@ class FeatureFlags { ...@@ -34,6 +34,9 @@ class FeatureFlags {
/// Whether flutter desktop for Windows is enabled. /// Whether flutter desktop for Windows is enabled.
bool get isWindowsEnabled => isEnabled(flutterWindowsDesktopFeature); bool get isWindowsEnabled => isEnabled(flutterWindowsDesktopFeature);
/// Whether fast single widget reloads are enabled.
bool get isSingleWidgetReloadEnabled => isEnabled(singleWidgetReload);
/// Whether a particular feature is enabled for the current channel. /// Whether a particular feature is enabled for the current channel.
/// ///
/// Prefer using one of the specific getters above instead of this API. /// Prefer using one of the specific getters above instead of this API.
...@@ -65,6 +68,7 @@ const List<Feature> allFeatures = <Feature>[ ...@@ -65,6 +68,7 @@ const List<Feature> allFeatures = <Feature>[
flutterLinuxDesktopFeature, flutterLinuxDesktopFeature,
flutterMacOSDesktopFeature, flutterMacOSDesktopFeature,
flutterWindowsDesktopFeature, flutterWindowsDesktopFeature,
singleWidgetReload,
]; ];
/// The [Feature] for flutter web. /// The [Feature] for flutter web.
...@@ -127,6 +131,28 @@ const Feature flutterWindowsDesktopFeature = Feature( ...@@ -127,6 +131,28 @@ const Feature flutterWindowsDesktopFeature = Feature(
), ),
); );
/// The fast hot reload feature for https://github.com/flutter/flutter/issues/61407.
const Feature singleWidgetReload = Feature(
name: 'Hot reload optimization for changes to class body of a single widget',
configSetting: 'single-widget-reload-optimization',
master: FeatureChannelSetting(
available: true,
enabledByDefault: false,
),
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. /// A [Feature] is a process for conditionally enabling tool features.
/// ///
/// All settings are optional, and if not provided will generally default to /// All settings are optional, and if not provided will generally default to
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -55,6 +56,20 @@ void main() { ...@@ -55,6 +56,20 @@ void main() {
expect(result.stdout, contains('Running shutdown hooks')); expect(result.stdout, contains('Running shutdown hooks'));
}); });
test('flutter config contains all features', () async {
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await const LocalProcessManager().run(<String>[
flutterBin,
'config',
]);
// contains all of the experiments in features.dart
expect(result.stdout.split('\n'), containsAll(<Matcher>[
for (final Feature feature in allFeatures)
contains(feature.configSetting),
]));
});
test('flutter run --machine uses AppRunLogger', () async { test('flutter run --machine uses AppRunLogger', () async {
final Directory directory = createResolvedTempDirectorySync('flutter_run_test.') final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
.createTempSync('_flutter_run_test.') .createTempSync('_flutter_run_test.')
......
...@@ -724,6 +724,7 @@ class TestFeatureFlags implements FeatureFlags { ...@@ -724,6 +724,7 @@ class TestFeatureFlags implements FeatureFlags {
this.isMacOSEnabled = false, this.isMacOSEnabled = false,
this.isWebEnabled = false, this.isWebEnabled = false,
this.isWindowsEnabled = false, this.isWindowsEnabled = false,
this.isSingleWidgetReloadEnabled = false,
}); });
@override @override
...@@ -738,6 +739,9 @@ class TestFeatureFlags implements FeatureFlags { ...@@ -738,6 +739,9 @@ class TestFeatureFlags implements FeatureFlags {
@override @override
final bool isWindowsEnabled; final bool isWindowsEnabled;
@override
final bool isSingleWidgetReloadEnabled;
@override @override
bool isEnabled(Feature feature) { bool isEnabled(Feature feature) {
switch (feature) { switch (feature) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment