Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
96a4dcb2
Unverified
Commit
96a4dcb2
authored
Apr 02, 2021
by
Jonah Williams
Committed by
GitHub
Apr 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] split features into 2 libraries, migrate to null safety (#79603)
parent
8743f94f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
82 deletions
+89
-82
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-0
features.dart
packages/flutter_tools/lib/src/features.dart
+6
-82
flutter_features.dart
packages/flutter_tools/lib/src/flutter_features.dart
+81
-0
features_test.dart
packages/flutter_tools/test/general.shard/features_test.dart
+1
-0
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
96a4dcb2
...
@@ -40,6 +40,7 @@ import 'emulator.dart';
...
@@ -40,6 +40,7 @@ import 'emulator.dart';
import
'features.dart'
;
import
'features.dart'
;
import
'flutter_application_package.dart'
;
import
'flutter_application_package.dart'
;
import
'flutter_device_manager.dart'
;
import
'flutter_device_manager.dart'
;
import
'flutter_features.dart'
;
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
import
'fuchsia/fuchsia_sdk.dart'
show
FuchsiaSdk
,
FuchsiaArtifacts
;
import
'fuchsia/fuchsia_sdk.dart'
show
FuchsiaSdk
,
FuchsiaArtifacts
;
import
'fuchsia/fuchsia_workflow.dart'
show
FuchsiaWorkflow
,
fuchsiaWorkflow
;
import
'fuchsia/fuchsia_workflow.dart'
show
FuchsiaWorkflow
,
fuchsiaWorkflow
;
...
...
packages/flutter_tools/lib/src/features.dart
View file @
96a4dcb2
...
@@ -2,19 +2,12 @@
...
@@ -2,19 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'base/config.dart'
;
import
'base/context.dart'
;
import
'base/context.dart'
;
import
'base/platform.dart'
;
import
'version.dart'
;
/// The current [FeatureFlags] implementation.
/// The current [FeatureFlags] implementation.
///
///
/// If not injected, a default implementation is provided.
/// If not injected, a default implementation is provided.
FeatureFlags
get
featureFlags
=>
context
.
get
<
FeatureFlags
>();
FeatureFlags
get
featureFlags
=>
context
.
get
<
FeatureFlags
>()
!
;
/// The interface used to determine if a particular [Feature] is enabled.
/// The interface used to determine if a particular [Feature] is enabled.
///
///
...
@@ -66,75 +59,6 @@ abstract class FeatureFlags {
...
@@ -66,75 +59,6 @@ abstract class FeatureFlags {
bool
isEnabled
(
Feature
feature
)
=>
false
;
bool
isEnabled
(
Feature
feature
)
=>
false
;
}
}
class
FlutterFeatureFlags
implements
FeatureFlags
{
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
bool
get
isLinuxEnabled
=>
isEnabled
(
flutterLinuxDesktopFeature
);
@override
bool
get
isMacOSEnabled
=>
isEnabled
(
flutterMacOSDesktopFeature
);
@override
bool
get
isWebEnabled
=>
isEnabled
(
flutterWebFeature
);
@override
bool
get
isWindowsEnabled
=>
isEnabled
(
flutterWindowsDesktopFeature
);
@override
bool
get
isAndroidEnabled
=>
isEnabled
(
flutterAndroidFeature
);
@override
bool
get
isIOSEnabled
=>
isEnabled
(
flutterIOSFeature
);
@override
bool
get
isFuchsiaEnabled
=>
isEnabled
(
flutterFuchsiaFeature
);
@override
bool
get
areCustomDevicesEnabled
=>
isEnabled
(
flutterCustomDevicesFeature
);
@override
bool
get
isSingleWidgetReloadEnabled
=>
isEnabled
(
singleWidgetReload
);
@override
bool
get
isExperimentalInvalidationStrategyEnabled
=>
isEnabled
(
experimentalInvalidationStrategy
);
@override
bool
get
isWindowsUwpEnabled
=>
isEnabled
(
windowsUwpEmbedding
);
@override
bool
isEnabled
(
Feature
feature
)
{
final
String
currentChannel
=
_flutterVersion
.
channel
;
final
FeatureChannelSetting
featureSetting
=
feature
.
getSettingForChannel
(
currentChannel
);
if
(!
featureSetting
.
available
)
{
return
false
;
}
bool
isEnabled
=
featureSetting
.
enabledByDefault
;
if
(
feature
.
configSetting
!=
null
)
{
final
bool
configOverride
=
_config
.
getValue
(
feature
.
configSetting
)
as
bool
;
if
(
configOverride
!=
null
)
{
isEnabled
=
configOverride
;
}
}
if
(
feature
.
environmentOverride
!=
null
)
{
if
(
_platform
.
environment
[
feature
.
environmentOverride
]?.
toLowerCase
()
==
'true'
)
{
isEnabled
=
true
;
}
}
return
isEnabled
;
}
}
/// All current Flutter feature flags.
/// All current Flutter feature flags.
const
List
<
Feature
>
allFeatures
=
<
Feature
>[
const
List
<
Feature
>
allFeatures
=
<
Feature
>[
flutterWebFeature
,
flutterWebFeature
,
...
@@ -393,7 +317,7 @@ const Feature windowsUwpEmbedding = Feature(
...
@@ -393,7 +317,7 @@ const Feature windowsUwpEmbedding = Feature(
class
Feature
{
class
Feature
{
/// Creates a [Feature].
/// Creates a [Feature].
const
Feature
({
const
Feature
({
@
required
this
.
name
,
required
this
.
name
,
this
.
environmentOverride
,
this
.
environmentOverride
,
this
.
configSetting
,
this
.
configSetting
,
this
.
extraHelpText
,
this
.
extraHelpText
,
...
@@ -425,20 +349,20 @@ class Feature {
...
@@ -425,20 +349,20 @@ class Feature {
/// a feature.
/// a feature.
///
///
/// If not provided, defaults to `null` meaning there is no override.
/// If not provided, defaults to `null` meaning there is no override.
final
String
environmentOverride
;
final
String
?
environmentOverride
;
/// The name of a setting that can be used to enable this feature.
/// The name of a setting that can be used to enable this feature.
///
///
/// If not provided, defaults to `null` meaning there is no config setting.
/// If not provided, defaults to `null` meaning there is no config setting.
final
String
configSetting
;
final
String
?
configSetting
;
/// Additional text to add to the end of the help message.
/// Additional text to add to the end of the help message.
///
///
/// If not provided, defaults to `null` meaning there is no additional text.
/// If not provided, defaults to `null` meaning there is no additional text.
final
String
extraHelpText
;
final
String
?
extraHelpText
;
/// A help message for the `flutter config` command, or null if unsupported.
/// A help message for the `flutter config` command, or null if unsupported.
String
generateHelpMessage
()
{
String
?
generateHelpMessage
()
{
if
(
configSetting
==
null
)
{
if
(
configSetting
==
null
)
{
return
null
;
return
null
;
}
}
...
...
packages/flutter_tools/lib/src/flutter_features.dart
0 → 100644
View file @
96a4dcb2
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'base/config.dart'
;
import
'base/platform.dart'
;
import
'features.dart'
;
import
'version.dart'
;
class
FlutterFeatureFlags
implements
FeatureFlags
{
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
bool
get
isLinuxEnabled
=>
isEnabled
(
flutterLinuxDesktopFeature
);
@override
bool
get
isMacOSEnabled
=>
isEnabled
(
flutterMacOSDesktopFeature
);
@override
bool
get
isWebEnabled
=>
isEnabled
(
flutterWebFeature
);
@override
bool
get
isWindowsEnabled
=>
isEnabled
(
flutterWindowsDesktopFeature
);
@override
bool
get
isAndroidEnabled
=>
isEnabled
(
flutterAndroidFeature
);
@override
bool
get
isIOSEnabled
=>
isEnabled
(
flutterIOSFeature
);
@override
bool
get
isFuchsiaEnabled
=>
isEnabled
(
flutterFuchsiaFeature
);
@override
bool
get
areCustomDevicesEnabled
=>
isEnabled
(
flutterCustomDevicesFeature
);
@override
bool
get
isSingleWidgetReloadEnabled
=>
isEnabled
(
singleWidgetReload
);
@override
bool
get
isExperimentalInvalidationStrategyEnabled
=>
isEnabled
(
experimentalInvalidationStrategy
);
@override
bool
get
isWindowsUwpEnabled
=>
isEnabled
(
windowsUwpEmbedding
);
@override
bool
isEnabled
(
Feature
feature
)
{
final
String
currentChannel
=
_flutterVersion
.
channel
;
final
FeatureChannelSetting
featureSetting
=
feature
.
getSettingForChannel
(
currentChannel
);
if
(!
featureSetting
.
available
)
{
return
false
;
}
bool
isEnabled
=
featureSetting
.
enabledByDefault
;
if
(
feature
.
configSetting
!=
null
)
{
final
bool
configOverride
=
_config
.
getValue
(
feature
.
configSetting
)
as
bool
;
if
(
configOverride
!=
null
)
{
isEnabled
=
configOverride
;
}
}
if
(
feature
.
environmentOverride
!=
null
)
{
if
(
_platform
.
environment
[
feature
.
environmentOverride
]?.
toLowerCase
()
==
'true'
)
{
isEnabled
=
true
;
}
}
return
isEnabled
;
}
}
packages/flutter_tools/test/general.shard/features_test.dart
View file @
96a4dcb2
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/flutter_features.dart'
;
import
'../src/common.dart'
;
import
'../src/common.dart'
;
import
'../src/fakes.dart'
;
import
'../src/fakes.dart'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment