Skip to content

Commit

Permalink
Cleanup flutter config output (#122384)
Browse files Browse the repository at this point in the history
  • Loading branch information
mit-mit committed Apr 21, 2023
1 parent d4f884e commit dc481b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
12 changes: 4 additions & 8 deletions packages/flutter_tools/lib/src/features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,17 @@ class Feature {
if (configSetting == null) {
return null;
}
final StringBuffer buffer = StringBuffer('Enable or disable $name. '
'This setting will take effect on ');
final StringBuffer buffer = StringBuffer('Enable or disable $name.');
final List<String> channels = <String>[
if (master.available) 'master',
if (beta.available) 'beta',
if (stable.available) 'stable',
];
// Add channel info for settings only on some channels.
if (channels.length == 1) {
buffer.write('the ${channels.single} channel.');
buffer.write('\nThis setting applies to only the ${channels.single} channel.');
} else if (channels.length == 2) {
buffer.write('the ${channels.join(' and ')} channels.');
} else {
final String prefix = (channels.toList()
..removeLast()).join(', ');
buffer.write('the $prefix, and ${channels.last} channels.');
buffer.write('\nThis setting applies to only the ${channels.join(' and ')} channels.');
}
if (extraHelpText != null) {
buffer.write(' $extraHelpText');
Expand Down
15 changes: 5 additions & 10 deletions packages/flutter_tools/test/general.shard/features_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,22 @@ void main() {

testWithoutContext('Flutter web help string', () {
expect(flutterWebFeature.generateHelpMessage(),
'Enable or disable Flutter for web. '
'This setting will take effect on the master, beta, and stable channels.');
'Enable or disable Flutter for web.');
});

testWithoutContext('Flutter macOS desktop help string', () {
expect(flutterMacOSDesktopFeature.generateHelpMessage(),
'Enable or disable support for desktop on macOS. '
'This setting will take effect on the master, beta, and stable channels.');
'Enable or disable support for desktop on macOS.');
});

testWithoutContext('Flutter Linux desktop help string', () {
expect(flutterLinuxDesktopFeature.generateHelpMessage(),
'Enable or disable support for desktop on Linux. '
'This setting will take effect on the master, beta, and stable channels.');
'Enable or disable support for desktop on Linux.');
});

testWithoutContext('Flutter Windows desktop help string', () {
expect(flutterWindowsDesktopFeature.generateHelpMessage(),
'Enable or disable support for desktop on Windows. '
'This setting will take effect on the master, beta, and stable channels.');
'Enable or disable support for desktop on Windows.');
});

testWithoutContext('help string on multiple channels', () {
Expand All @@ -120,8 +116,7 @@ void main() {
configSetting: 'foo',
);

expect(testWithoutContextFeature.generateHelpMessage(), 'Enable or disable example. '
'This setting will take effect on the master, beta, and stable channels.');
expect(testWithoutContextFeature.generateHelpMessage(), 'Enable or disable example.');
});

/// Flutter Web
Expand Down

0 comments on commit dc481b2

Please sign in to comment.