Unverified Commit e6535f6d authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Changed tool cached properties to late finals (#88923)

parent c690f143
...@@ -169,8 +169,7 @@ class AndroidSdk { ...@@ -169,8 +169,7 @@ class AndroidSdk {
AndroidSdkVersion? get latestVersion => _latestVersion; AndroidSdkVersion? get latestVersion => _latestVersion;
String? get adbPath => _adbPath ??= getPlatformToolsPath(globals.platform.isWindows ? 'adb.exe' : 'adb'); late final String? adbPath = getPlatformToolsPath(globals.platform.isWindows ? 'adb.exe' : 'adb');
String? _adbPath;
String? get emulatorPath => getEmulatorPath(); String? get emulatorPath => getEmulatorPath();
......
...@@ -163,8 +163,7 @@ class Cache { ...@@ -163,8 +163,7 @@ class Cache {
final Net _net; final Net _net;
final FileSystemUtils _fsUtils; final FileSystemUtils _fsUtils;
ArtifactUpdater get _artifactUpdater => __artifactUpdater ??= _createUpdater(); late final ArtifactUpdater _artifactUpdater = _createUpdater();
ArtifactUpdater? __artifactUpdater;
@protected @protected
void registerArtifact(ArtifactSet artifactSet) { void registerArtifact(ArtifactSet artifactSet) {
......
...@@ -97,13 +97,11 @@ class WindowsUwpProject extends WindowsProject { ...@@ -97,13 +97,11 @@ class WindowsUwpProject extends WindowsProject {
int? get projectVersion => int.tryParse(_editableDirectory.childFile('project_version').readAsStringSync()); int? get projectVersion => int.tryParse(_editableDirectory.childFile('project_version').readAsStringSync());
/// Retrieve the GUID of the UWP package. /// Retrieve the GUID of the UWP package.
String? get packageGuid => _packageGuid ??= getCmakePackageGuid(runnerCmakeFile); late final String? packageGuid = getCmakePackageGuid(runnerCmakeFile);
String? _packageGuid;
File get appManifest => _editableDirectory.childDirectory('runner_uwp').childFile('appxmanifest.in'); File get appManifest => _editableDirectory.childDirectory('runner_uwp').childFile('appxmanifest.in');
String? get packageVersion => _packageVersion ??= parseAppVersion(this); late final String? packageVersion = parseAppVersion(this);
String? _packageVersion;
} }
@visibleForTesting @visibleForTesting
......
...@@ -50,8 +50,7 @@ class IMobileDevice { ...@@ -50,8 +50,7 @@ class IMobileDevice {
final ProcessManager _processManager; final ProcessManager _processManager;
final ProcessUtils _processUtils; final ProcessUtils _processUtils;
bool get isInstalled => _isInstalled ??= _processManager.canRun(_idevicescreenshotPath); late final bool isInstalled = _processManager.canRun(_idevicescreenshotPath);
bool? _isInstalled;
/// Starts `idevicesyslog` and returns the running process. /// Starts `idevicesyslog` and returns the running process.
Future<Process> startLogger(String deviceID) { Future<Process> startLogger(String deviceID) {
......
...@@ -106,10 +106,8 @@ class AndroidPlugin extends PluginPlatform { ...@@ -106,10 +106,8 @@ class AndroidPlugin extends PluginPlatform {
}; };
} }
Set<String>? _cachedEmbeddingVersion;
/// Returns the version of the Android embedding. /// Returns the version of the Android embedding.
Set<String> get _supportedEmbeddings => _cachedEmbeddingVersion ??= _getSupportedEmbeddings(); late final Set<String> _supportedEmbeddings = _getSupportedEmbeddings();
Set<String> _getSupportedEmbeddings() { Set<String> _getSupportedEmbeddings() {
assert(pluginPath != null); assert(pluginPath != null);
......
...@@ -163,36 +163,28 @@ class FlutterProject { ...@@ -163,36 +163,28 @@ class FlutterProject {
} }
/// The iOS sub project of this project. /// The iOS sub project of this project.
IosProject? _ios; late final IosProject ios = IosProject.fromFlutter(this);
IosProject get ios => _ios ??= IosProject.fromFlutter(this);
/// The Android sub project of this project. /// The Android sub project of this project.
AndroidProject? _android; late final AndroidProject android = AndroidProject._(this);
AndroidProject get android => _android ??= AndroidProject._(this);
/// The web sub project of this project. /// The web sub project of this project.
WebProject? _web; late final WebProject web = WebProject._(this);
WebProject get web => _web ??= WebProject._(this);
/// The MacOS sub project of this project. /// The MacOS sub project of this project.
MacOSProject? _macos; late final MacOSProject macos = MacOSProject.fromFlutter(this);
MacOSProject get macos => _macos ??= MacOSProject.fromFlutter(this);
/// The Linux sub project of this project. /// The Linux sub project of this project.
LinuxProject? _linux; late final LinuxProject linux = LinuxProject.fromFlutter(this);
LinuxProject get linux => _linux ??= LinuxProject.fromFlutter(this);
/// The Windows sub project of this project. /// The Windows sub project of this project.
WindowsProject? _windows; late final WindowsProject windows = WindowsProject.fromFlutter(this);
WindowsProject get windows => _windows ??= WindowsProject.fromFlutter(this);
/// The Windows UWP sub project of this project. /// The Windows UWP sub project of this project.
WindowsUwpProject? _windowUwp; late final WindowsUwpProject windowsUwp = WindowsUwpProject.fromFlutter(this);
WindowsUwpProject get windowsUwp => _windowUwp ??= WindowsUwpProject.fromFlutter(this);
/// The Fuchsia sub project of this project. /// The Fuchsia sub project of this project.
FuchsiaProject? _fuchsia; late final FuchsiaProject fuchsia = FuchsiaProject._(this);
FuchsiaProject get fuchsia => _fuchsia ??= FuchsiaProject._(this);
/// The `pubspec.yaml` file of this project. /// The `pubspec.yaml` file of this project.
File get pubspecFile => directory.childFile('pubspec.yaml'); File get pubspecFile => directory.childFile('pubspec.yaml');
...@@ -414,8 +406,7 @@ class AndroidProject extends FlutterProjectPlatform { ...@@ -414,8 +406,7 @@ class AndroidProject extends FlutterProjectPlatform {
bool get usesAndroidX => parent.usesAndroidX; bool get usesAndroidX => parent.usesAndroidX;
/// Returns true if the current version of the Gradle plugin is supported. /// Returns true if the current version of the Gradle plugin is supported.
bool get isSupportedVersion => _isSupportedVersion ??= _computeSupportedVersion(); late final bool isSupportedVersion = _computeSupportedVersion();
bool? _isSupportedVersion;
bool _computeSupportedVersion() { bool _computeSupportedVersion() {
final FileSystem fileSystem = hostAppGradleRoot.fileSystem; final FileSystem fileSystem = hostAppGradleRoot.fileSystem;
......
...@@ -10,15 +10,10 @@ import '../globals_null_migrated.dart' as globals; ...@@ -10,15 +10,10 @@ import '../globals_null_migrated.dart' as globals;
/// Manages a Font configuration that can be shared across multiple tests. /// Manages a Font configuration that can be shared across multiple tests.
class FontConfigManager { class FontConfigManager {
Directory? _fontsDirectory; Directory? _fontsDirectory;
File? _cachedFontConfig;
/// Returns a Font configuration that limits font fallback to the artifact /// Returns a Font configuration that limits font fallback to the artifact
/// cache directory. /// cache directory.
File get fontConfigFile { late final File fontConfigFile = (){
if (_cachedFontConfig != null) {
return _cachedFontConfig!;
}
final StringBuffer sb = StringBuffer(); final StringBuffer sb = StringBuffer();
sb.writeln('<fontconfig>'); sb.writeln('<fontconfig>');
sb.writeln(' <dir>${globals.cache.getCacheArtifacts().path}</dir>'); sb.writeln(' <dir>${globals.cache.getCacheArtifacts().path}</dir>');
...@@ -30,11 +25,11 @@ class FontConfigManager { ...@@ -30,11 +25,11 @@ class FontConfigManager {
globals.printTrace('Using this directory for fonts configuration: ${_fontsDirectory!.path}'); globals.printTrace('Using this directory for fonts configuration: ${_fontsDirectory!.path}');
} }
_cachedFontConfig = globals.fs.file('${_fontsDirectory!.path}/fonts.conf'); final File cachedFontConfig = globals.fs.file('${_fontsDirectory!.path}/fonts.conf');
_cachedFontConfig!.createSync(); cachedFontConfig.createSync();
_cachedFontConfig!.writeAsStringSync(sb.toString()); cachedFontConfig.writeAsStringSync(sb.toString());
return _cachedFontConfig!; return cachedFontConfig;
} }();
Future<void> dispose() async { Future<void> dispose() async {
if (_fontsDirectory != null) { if (_fontsDirectory != null) {
......
...@@ -348,11 +348,7 @@ class VisualStudio { ...@@ -348,11 +348,7 @@ class VisualStudio {
/// ///
/// If no installation is found, the cached VS details are set to an empty map /// If no installation is found, the cached VS details are set to an empty map
/// to avoid repeating vswhere queries that have already not found an installation. /// to avoid repeating vswhere queries that have already not found an installation.
Map<String, dynamic>? _cachedUsableVisualStudioDetails; late final Map<String, dynamic> _usableVisualStudioDetails = (){
Map<String, dynamic> get _usableVisualStudioDetails {
if (_cachedUsableVisualStudioDetails != null) {
return _cachedUsableVisualStudioDetails!;
}
final List<String> minimumVersionArguments = <String>[ final List<String> minimumVersionArguments = <String>[
_vswhereMinVersionArgument, _vswhereMinVersionArgument,
_minimumSupportedVersion.toString(), _minimumSupportedVersion.toString(),
...@@ -370,16 +366,16 @@ class VisualStudio { ...@@ -370,16 +366,16 @@ class VisualStudio {
} }
} }
Map<String, dynamic>? usableVisualStudioDetails;
if (visualStudioDetails != null) { if (visualStudioDetails != null) {
if (installationHasIssues(visualStudioDetails)) { if (installationHasIssues(visualStudioDetails)) {
_cachedAnyVisualStudioDetails = visualStudioDetails; _cachedAnyVisualStudioDetails = visualStudioDetails;
} else { } else {
_cachedUsableVisualStudioDetails = visualStudioDetails; usableVisualStudioDetails = visualStudioDetails;
} }
} }
_cachedUsableVisualStudioDetails ??= <String, dynamic>{}; return usableVisualStudioDetails ?? <String, dynamic>{};
return _cachedUsableVisualStudioDetails!; }();
}
/// Returns the details dictionary of the latest version of Visual Studio, /// Returns the details dictionary of the latest version of Visual Studio,
/// regardless of components and version, or {} if no such installation is /// regardless of components and version, or {} if no such installation is
......
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