[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.
This commit is contained in:
Jonah Williams 2020-07-14 12:24:58 -07:00 committed by GitHub
parent 74f3e6dd63
commit d22d65c6e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -34,6 +34,9 @@ class FeatureFlags {
/// Whether flutter desktop for Windows is enabled.
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.
///
/// Prefer using one of the specific getters above instead of this API.
@ -65,6 +68,7 @@ const List<Feature> allFeatures = <Feature>[
flutterLinuxDesktopFeature,
flutterMacOSDesktopFeature,
flutterWindowsDesktopFeature,
singleWidgetReload,
];
/// The [Feature] for flutter web.
@ -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.
///
/// All settings are optional, and if not provided will generally default to

View File

@ -4,6 +4,7 @@
import 'package:flutter_tools/src/base/file_system.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:process/process.dart';
@ -55,6 +56,20 @@ void main() {
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 {
final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
.createTempSync('_flutter_run_test.')

View File

@ -724,6 +724,7 @@ class TestFeatureFlags implements FeatureFlags {
this.isMacOSEnabled = false,
this.isWebEnabled = false,
this.isWindowsEnabled = false,
this.isSingleWidgetReloadEnabled = false,
});
@override
@ -738,6 +739,9 @@ class TestFeatureFlags implements FeatureFlags {
@override
final bool isWindowsEnabled;
@override
final bool isSingleWidgetReloadEnabled;
@override
bool isEnabled(Feature feature) {
switch (feature) {