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