mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] remove remaining extensions (#76743)
This commit is contained in:
parent
fe2708c35b
commit
d60e9de75d
@ -255,7 +255,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
|
||||
|
||||
if (!result.success) {
|
||||
await diagnoseXcodeBuildFailure(result, globals.flutterUsage, globals.logger);
|
||||
throwToolExit('Encountered error while ${xcodeBuildAction.name}ing for $logTarget.');
|
||||
throwToolExit('Encountered error while ${xcodeBuildActionToString(xcodeBuildAction)}ing for $logTarget.');
|
||||
}
|
||||
|
||||
if (buildInfo.codeSizeDirectory != null) {
|
||||
|
@ -34,17 +34,17 @@ class CreateCommand extends CreateBase {
|
||||
argParser.addOption(
|
||||
'template',
|
||||
abbr: 't',
|
||||
allowed: FlutterProjectType.values.map<String>((FlutterProjectType type) => type.name),
|
||||
allowed: FlutterProjectType.values.map<String>(flutterProjectTypeToString),
|
||||
help: 'Specify the type of project to create.',
|
||||
valueHelp: 'type',
|
||||
allowedHelp: <String, String>{
|
||||
FlutterProjectType.app.name: '(default) Generate a Flutter application.',
|
||||
FlutterProjectType.package.name: 'Generate a shareable Flutter project containing modular '
|
||||
flutterProjectTypeToString(FlutterProjectType.app): '(default) Generate a Flutter application.',
|
||||
flutterProjectTypeToString(FlutterProjectType.package): 'Generate a shareable Flutter project containing modular '
|
||||
'Dart code.',
|
||||
FlutterProjectType.plugin.name: 'Generate a shareable Flutter project containing an API '
|
||||
flutterProjectTypeToString(FlutterProjectType.plugin): 'Generate a shareable Flutter project containing an API '
|
||||
'in Dart code with a platform-specific implementation for Android, for iOS code, or '
|
||||
'for both.',
|
||||
FlutterProjectType.module.name: 'Generate a project to add a Flutter module to an '
|
||||
flutterProjectTypeToString(FlutterProjectType.module): 'Generate a project to add a Flutter module to an '
|
||||
'existing Android or iOS application.',
|
||||
},
|
||||
defaultsTo: null,
|
||||
@ -168,8 +168,8 @@ class CreateCommand extends CreateBase {
|
||||
if (detectedProjectType != null && template != detectedProjectType && metadataExists) {
|
||||
// We can only be definitive that this is the wrong type if the .metadata file
|
||||
// exists and contains a type that doesn't match.
|
||||
throwToolExit("The requested template type '${template.name}' doesn't match the "
|
||||
"existing template type of '${detectedProjectType.name}'.");
|
||||
throwToolExit("The requested template type '${flutterProjectTypeToString(template)}' doesn't match the "
|
||||
"existing template type of '${flutterProjectTypeToString(detectedProjectType)}'.");
|
||||
}
|
||||
return template;
|
||||
}
|
||||
@ -189,7 +189,7 @@ class CreateCommand extends CreateBase {
|
||||
if (argResults['template'] != null &&
|
||||
stringToProjectType(stringArg('template') ?? 'app') != FlutterProjectType.app) {
|
||||
throwToolExit('Cannot specify --sample with a project type other than '
|
||||
'"${FlutterProjectType.app.name}"');
|
||||
'"${flutterProjectTypeToString(FlutterProjectType.app)}"');
|
||||
}
|
||||
// Fetch the sample from the server.
|
||||
sampleCode = await _fetchSampleFromServer(stringArg('sample'));
|
||||
|
@ -25,14 +25,14 @@ enum FlutterProjectType {
|
||||
plugin,
|
||||
}
|
||||
|
||||
extension FlutterProjectTypeExtension on FlutterProjectType {
|
||||
String get name => getEnumName(this);
|
||||
String flutterProjectTypeToString(FlutterProjectType type) {
|
||||
return getEnumName(type);
|
||||
}
|
||||
|
||||
FlutterProjectType stringToProjectType(String value) {
|
||||
FlutterProjectType result;
|
||||
for (final FlutterProjectType type in FlutterProjectType.values) {
|
||||
if (value == type.name) {
|
||||
if (value == flutterProjectTypeToString(type)) {
|
||||
result = type;
|
||||
break;
|
||||
}
|
||||
|
@ -346,10 +346,10 @@ Future<XcodeBuildResult> buildXcodeProject({
|
||||
initialBuildStatus?.cancel();
|
||||
initialBuildStatus = null;
|
||||
globals.printStatus(
|
||||
'Xcode ${buildAction.name} done.'.padRight(kDefaultStatusPadding + 1)
|
||||
'Xcode ${xcodeBuildActionToString(buildAction)} done.'.padRight(kDefaultStatusPadding + 1)
|
||||
+ getElapsedAsSeconds(sw.elapsed).padLeft(5),
|
||||
);
|
||||
globals.flutterUsage.sendTiming(buildAction.name, 'xcode-ios', Duration(milliseconds: sw.elapsedMilliseconds));
|
||||
globals.flutterUsage.sendTiming(xcodeBuildActionToString(buildAction), 'xcode-ios', Duration(milliseconds: sw.elapsedMilliseconds));
|
||||
|
||||
// Run -showBuildSettings again but with the exact same parameters as the
|
||||
// build. showBuildSettings is reported to occasionally timeout. Here, we give
|
||||
@ -592,9 +592,8 @@ Future<void> diagnoseXcodeBuildFailure(XcodeBuildResult result, Usage flutterUsa
|
||||
/// `clean`, `test`, `analyze`, and `install` are not supported.
|
||||
enum XcodeBuildAction { build, archive }
|
||||
|
||||
extension XcodeBuildActionExtension on XcodeBuildAction {
|
||||
String get name {
|
||||
switch (this) {
|
||||
String xcodeBuildActionToString(XcodeBuildAction action) {
|
||||
switch (action) {
|
||||
case XcodeBuildAction.build:
|
||||
return 'build';
|
||||
case XcodeBuildAction.archive:
|
||||
@ -602,7 +601,6 @@ extension XcodeBuildActionExtension on XcodeBuildAction {
|
||||
default:
|
||||
throw UnsupportedError('Unknown Xcode build action');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class XcodeBuildResult {
|
||||
|
@ -121,7 +121,7 @@ ${_projectMetadataInformation()}
|
||||
}
|
||||
final FlutterProjectMetadata metadata = FlutterProjectMetadata(project.metadataFile, _logger);
|
||||
final StringBuffer description = StringBuffer()
|
||||
..writeln('**Type**: ${metadata.projectType?.name}')
|
||||
..writeln('**Type**: ${flutterProjectTypeToString(metadata.projectType)}')
|
||||
..writeln('**Version**: ${manifest.appVersion}')
|
||||
..writeln('**Material**: ${manifest.usesMaterialDesign}')
|
||||
..writeln('**Android X**: ${manifest.usesAndroidX}')
|
||||
|
Loading…
Reference in New Issue
Block a user