Arrow syntax for getters (#156483)
This egotistical PR aims to draw attention to a [style guideline](https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#use--for-getters-and-callbacks-that-just-return-literals-or-switch-expressions) that I changed: > #### Use `=>` for getters and callbacks that just return literals or switch expressions <br> There was an opportunity for valuable discussion in #154753 about how this structure affects readability, but I shut it down pretty quick since there was a lot of other stuff going on there. Interested to hear thoughts from @Piinks and others.
This commit is contained in:
@@ -123,14 +123,12 @@ class Java {
|
||||
///
|
||||
/// This map should be used as the environment when invoking any Java-dependent
|
||||
/// processes, such as Gradle or Android SDK tools (avdmanager, sdkmanager, etc.)
|
||||
Map<String, String> get environment {
|
||||
return <String, String>{
|
||||
if (javaHome != null) javaHomeEnvironmentVariable: javaHome!,
|
||||
'PATH': _fileSystem.path.dirname(binaryPath) +
|
||||
_os.pathVarSeparator +
|
||||
_platform.environment['PATH']!,
|
||||
};
|
||||
}
|
||||
Map<String, String> get environment => <String, String>{
|
||||
if (javaHome != null) javaHomeEnvironmentVariable: javaHome!,
|
||||
'PATH': _fileSystem.path.dirname(binaryPath) +
|
||||
_os.pathVarSeparator +
|
||||
_platform.environment['PATH']!,
|
||||
};
|
||||
|
||||
/// Returns the version of java in the format \d(.\d)+(.\d)+
|
||||
/// Returns null if version could not be determined.
|
||||
|
||||
@@ -633,16 +633,14 @@ enum HostPlatform {
|
||||
windows_x64,
|
||||
windows_arm64;
|
||||
|
||||
String get platformName {
|
||||
return switch (this) {
|
||||
HostPlatform.darwin_x64 => 'x64',
|
||||
HostPlatform.darwin_arm64 => 'arm64',
|
||||
HostPlatform.linux_x64 => 'x64',
|
||||
HostPlatform.linux_arm64 => 'arm64',
|
||||
HostPlatform.windows_x64 => 'x64',
|
||||
HostPlatform.windows_arm64 => 'arm64',
|
||||
};
|
||||
}
|
||||
String get platformName => switch (this) {
|
||||
HostPlatform.darwin_x64 => 'x64',
|
||||
HostPlatform.darwin_arm64 => 'arm64',
|
||||
HostPlatform.linux_x64 => 'x64',
|
||||
HostPlatform.linux_arm64 => 'arm64',
|
||||
HostPlatform.windows_x64 => 'x64',
|
||||
HostPlatform.windows_arm64 => 'arm64',
|
||||
};
|
||||
}
|
||||
|
||||
String getNameForHostPlatform(HostPlatform platform) {
|
||||
|
||||
@@ -649,23 +649,19 @@ enum AndroidArch {
|
||||
x86,
|
||||
x86_64;
|
||||
|
||||
String get archName {
|
||||
return switch (this) {
|
||||
AndroidArch.armeabi_v7a => 'armeabi-v7a',
|
||||
AndroidArch.arm64_v8a => 'arm64-v8a',
|
||||
AndroidArch.x86_64 => 'x86_64',
|
||||
AndroidArch.x86 => 'x86'
|
||||
};
|
||||
}
|
||||
String get archName => switch (this) {
|
||||
AndroidArch.armeabi_v7a => 'armeabi-v7a',
|
||||
AndroidArch.arm64_v8a => 'arm64-v8a',
|
||||
AndroidArch.x86_64 => 'x86_64',
|
||||
AndroidArch.x86 => 'x86',
|
||||
};
|
||||
|
||||
String get platformName {
|
||||
return switch (this) {
|
||||
AndroidArch.armeabi_v7a => 'android-arm',
|
||||
AndroidArch.arm64_v8a => 'android-arm64',
|
||||
AndroidArch.x86_64 => 'android-x64',
|
||||
AndroidArch.x86 => 'android-x86'
|
||||
};
|
||||
}
|
||||
String get platformName => switch (this) {
|
||||
AndroidArch.armeabi_v7a => 'android-arm',
|
||||
AndroidArch.arm64_v8a => 'android-arm64',
|
||||
AndroidArch.x86_64 => 'android-x64',
|
||||
AndroidArch.x86 => 'android-x86',
|
||||
};
|
||||
}
|
||||
|
||||
/// The default set of iOS device architectures to build for.
|
||||
|
||||
@@ -240,13 +240,11 @@ class AnalysisError implements Comparable<AnalysisError> {
|
||||
|
||||
String get _separator => _platform.isWindows ? '-' : '•';
|
||||
|
||||
String get colorSeverity {
|
||||
return switch (writtenError.severityLevel) {
|
||||
AnalysisSeverity.error => _terminal.color(writtenError.severity, TerminalColor.red),
|
||||
AnalysisSeverity.warning => _terminal.color(writtenError.severity, TerminalColor.yellow),
|
||||
AnalysisSeverity.info || AnalysisSeverity.none => writtenError.severity,
|
||||
};
|
||||
}
|
||||
String get colorSeverity => switch (writtenError.severityLevel) {
|
||||
AnalysisSeverity.error => _terminal.color(writtenError.severity, TerminalColor.red),
|
||||
AnalysisSeverity.warning => _terminal.color(writtenError.severity, TerminalColor.yellow),
|
||||
AnalysisSeverity.info || AnalysisSeverity.none => writtenError.severity,
|
||||
};
|
||||
|
||||
String get type => writtenError.type;
|
||||
String get code => writtenError.code;
|
||||
|
||||
@@ -161,14 +161,12 @@ class ValidationResult {
|
||||
final String? statusInfo;
|
||||
final List<ValidationMessage> messages;
|
||||
|
||||
String get leadingBox {
|
||||
return switch (type) {
|
||||
ValidationType.crash => '[☠]',
|
||||
ValidationType.missing => '[✗]',
|
||||
ValidationType.success => '[✓]',
|
||||
ValidationType.notAvailable || ValidationType.partial => '[!]',
|
||||
};
|
||||
}
|
||||
String get leadingBox => switch (type) {
|
||||
ValidationType.crash => '[☠]',
|
||||
ValidationType.missing => '[✗]',
|
||||
ValidationType.success => '[✓]',
|
||||
ValidationType.notAvailable || ValidationType.partial => '[!]',
|
||||
};
|
||||
|
||||
String get coloredLeadingBox {
|
||||
return globals.terminal.color(leadingBox, switch (type) {
|
||||
@@ -179,15 +177,13 @@ class ValidationResult {
|
||||
}
|
||||
|
||||
/// The string representation of the type.
|
||||
String get typeStr {
|
||||
return switch (type) {
|
||||
ValidationType.crash => 'crash',
|
||||
ValidationType.missing => 'missing',
|
||||
ValidationType.success => 'installed',
|
||||
ValidationType.notAvailable => 'notAvailable',
|
||||
ValidationType.partial => 'partial',
|
||||
};
|
||||
}
|
||||
String get typeStr => switch (type) {
|
||||
ValidationType.crash => 'crash',
|
||||
ValidationType.missing => 'missing',
|
||||
ValidationType.success => 'installed',
|
||||
ValidationType.notAvailable => 'notAvailable',
|
||||
ValidationType.partial => 'partial',
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@@ -237,13 +233,11 @@ class ValidationMessage {
|
||||
|
||||
bool get isInformation => type == ValidationMessageType.information;
|
||||
|
||||
String get indicator {
|
||||
return switch (type) {
|
||||
ValidationMessageType.error => '✗',
|
||||
ValidationMessageType.hint => '!',
|
||||
ValidationMessageType.information => '•',
|
||||
};
|
||||
}
|
||||
String get indicator => switch (type) {
|
||||
ValidationMessageType.error => '✗',
|
||||
ValidationMessageType.hint => '!',
|
||||
ValidationMessageType.information => '•',
|
||||
};
|
||||
|
||||
String get coloredIndicator {
|
||||
return globals.terminal.color(indicator, switch (type) {
|
||||
|
||||
@@ -801,11 +801,9 @@ class IosUsbArtifacts extends CachedArtifact {
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, String> get environment {
|
||||
return <String, String>{
|
||||
'DYLD_LIBRARY_PATH': cache.getArtifactDirectory(name).path,
|
||||
};
|
||||
}
|
||||
Map<String, String> get environment => <String, String>{
|
||||
'DYLD_LIBRARY_PATH': cache.getArtifactDirectory(name).path,
|
||||
};
|
||||
|
||||
@override
|
||||
bool isUpToDateInner(FileSystem fileSystem) {
|
||||
|
||||
@@ -91,17 +91,15 @@ class SwiftPackage {
|
||||
final TemplateRenderer _templateRenderer;
|
||||
|
||||
/// Context for the [_swiftPackageTemplate] template.
|
||||
Map<String, Object> get _templateContext {
|
||||
return <String, Object>{
|
||||
'swiftToolsVersion': minimumSwiftToolchainVersion,
|
||||
'packageName': _name,
|
||||
// Supported platforms can't be empty, so only include if not null.
|
||||
'platforms': _formatPlatforms() ?? false,
|
||||
'products': _formatProducts(),
|
||||
'dependencies': _formatDependencies(),
|
||||
'targets': _formatTargets(),
|
||||
};
|
||||
}
|
||||
Map<String, Object> get _templateContext => <String, Object>{
|
||||
'swiftToolsVersion': minimumSwiftToolchainVersion,
|
||||
'packageName': _name,
|
||||
// Supported platforms can't be empty, so only include if not null.
|
||||
'platforms': _formatPlatforms() ?? false,
|
||||
'products': _formatProducts(),
|
||||
'dependencies': _formatDependencies(),
|
||||
'targets': _formatTargets(),
|
||||
};
|
||||
|
||||
/// Create a Package.swift using settings from [_templateContext].
|
||||
void createSwiftPackage() {
|
||||
|
||||
@@ -1247,13 +1247,11 @@ class FakeAsyncCrashingDoctor extends Doctor {
|
||||
/// overriding the doctor.
|
||||
class FakeDoctorValidatorsProvider implements DoctorValidatorsProvider {
|
||||
@override
|
||||
List<DoctorValidator> get validators {
|
||||
return <DoctorValidator>[
|
||||
PassingValidator('Passing Validator'),
|
||||
PassingValidator('Another Passing Validator'),
|
||||
PassingValidator('Providing validators is fun'),
|
||||
];
|
||||
}
|
||||
List<DoctorValidator> get validators => <DoctorValidator>[
|
||||
PassingValidator('Passing Validator'),
|
||||
PassingValidator('Another Passing Validator'),
|
||||
PassingValidator('Providing validators is fun'),
|
||||
];
|
||||
|
||||
@override
|
||||
List<Workflow> get workflows => <Workflow>[];
|
||||
|
||||
Reference in New Issue
Block a user