Unverified Commit 9618788e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove globals from features (#70515)

parent 148ae7bf
...@@ -185,7 +185,11 @@ Future<T> runInContext<T>( ...@@ -185,7 +185,11 @@ Future<T> runInContext<T>(
fileSystem: globals.fs, fileSystem: globals.fs,
androidWorkflow: androidWorkflow, androidWorkflow: androidWorkflow,
), ),
FeatureFlags: () => const FlutterFeatureFlags(), FeatureFlags: () => FlutterFeatureFlags(
flutterVersion: globals.flutterVersion,
config: globals.config,
platform: globals.platform,
),
FlutterVersion: () => FlutterVersion(clock: const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
FuchsiaArtifacts: () => FuchsiaArtifacts.find(), FuchsiaArtifacts: () => FuchsiaArtifacts.find(),
FuchsiaDeviceTools: () => FuchsiaDeviceTools(), FuchsiaDeviceTools: () => FuchsiaDeviceTools(),
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'base/config.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'globals.dart' as globals; import 'base/platform.dart';
import 'version.dart';
/// The current [FeatureFlags] implementation. /// The current [FeatureFlags] implementation.
/// ///
...@@ -54,7 +56,17 @@ abstract class FeatureFlags { ...@@ -54,7 +56,17 @@ abstract class FeatureFlags {
} }
class FlutterFeatureFlags implements FeatureFlags { class FlutterFeatureFlags implements FeatureFlags {
const FlutterFeatureFlags(); FlutterFeatureFlags({
@required FlutterVersion flutterVersion,
@required Config config,
@required Platform platform,
}) : _flutterVersion = flutterVersion,
_config = config,
_platform = platform;
final FlutterVersion _flutterVersion;
final Config _config;
final Platform _platform;
@override @override
bool get isLinuxEnabled => isEnabled(flutterLinuxDesktopFeature); bool get isLinuxEnabled => isEnabled(flutterLinuxDesktopFeature);
...@@ -82,20 +94,20 @@ class FlutterFeatureFlags implements FeatureFlags { ...@@ -82,20 +94,20 @@ class FlutterFeatureFlags implements FeatureFlags {
@override @override
bool isEnabled(Feature feature) { bool isEnabled(Feature feature) {
final String currentChannel = globals.flutterVersion.channel; final String currentChannel = _flutterVersion.channel;
final FeatureChannelSetting featureSetting = feature.getSettingForChannel(currentChannel); final FeatureChannelSetting featureSetting = feature.getSettingForChannel(currentChannel);
if (!featureSetting.available) { if (!featureSetting.available) {
return false; return false;
} }
bool isEnabled = featureSetting.enabledByDefault; bool isEnabled = featureSetting.enabledByDefault;
if (feature.configSetting != null) { if (feature.configSetting != null) {
final bool configOverride = globals.config.getValue(feature.configSetting) as bool; final bool configOverride = _config.getValue(feature.configSetting) as bool;
if (configOverride != null) { if (configOverride != null) {
isEnabled = configOverride; isEnabled = configOverride;
} }
} }
if (feature.environmentOverride != null) { if (feature.environmentOverride != null) {
if (globals.platform.environment[feature.environmentOverride]?.toLowerCase() == 'true') { if (_platform.environment[feature.environmentOverride]?.toLowerCase() == 'true') {
isEnabled = true; isEnabled = true;
} }
} }
......
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