Skip to content

Commit 240825a

Browse files
authored
Enable private field promotion for flutter_tools (flutter#134474)
New feature in upcoming Dart 3.2. See dart-lang/language#2020. Feature is enabled by bumping the min SDK version to 3.2. Part of flutter#134476.
1 parent 0573340 commit 240825a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+98
-98
lines changed

packages/flutter_tools/lib/src/android/android_device_discovery.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
105105

106106
bool _doesNotHaveAdb() {
107107
return _androidSdk == null ||
108-
_androidSdk?.adbPath == null ||
109-
!_processManager.canRun(_androidSdk!.adbPath);
108+
_androidSdk.adbPath == null ||
109+
!_processManager.canRun(_androidSdk.adbPath);
110110
}
111111

112112
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper

packages/flutter_tools/lib/src/android/android_emulator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class AndroidEmulator extends Emulator {
141141
@override
142142
PlatformType get platformType => PlatformType.android;
143143

144-
String? _prop(String name) => _properties != null ? _properties![name] : null;
144+
String? _prop(String name) => _properties != null ? _properties[name] : null;
145145

146146
@override
147147
Future<void> launch({@visibleForTesting Duration? startupDuration, bool coldBoot = false}) async {

packages/flutter_tools/lib/src/android/android_workflow.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class AndroidWorkflow implements Workflow {
5353

5454
@override
5555
bool get canListDevices => appliesToHostPlatform && _androidSdk != null
56-
&& _androidSdk?.adbPath != null;
56+
&& _androidSdk.adbPath != null;
5757

5858
@override
5959
bool get canLaunchDevices => appliesToHostPlatform && _androidSdk != null
60-
&& _androidSdk?.adbPath != null
61-
&& (_androidSdk?.validateSdkWellFormed().isEmpty ?? false);
60+
&& _androidSdk.adbPath != null
61+
&& _androidSdk.validateSdkWellFormed().isEmpty;
6262

6363
@override
6464
bool get canListEmulators => canListDevices && _androidSdk?.emulatorPath != null;
@@ -105,13 +105,13 @@ class AndroidValidator extends DoctorValidator {
105105
return false;
106106
}
107107
messages.add(ValidationMessage(_userMessages.androidJdkLocation(_java!.binaryPath)));
108-
if (!_java!.canRun()) {
109-
messages.add(ValidationMessage.error(_userMessages.androidCantRunJavaBinary(_java!.binaryPath)));
108+
if (!_java.canRun()) {
109+
messages.add(ValidationMessage.error(_userMessages.androidCantRunJavaBinary(_java.binaryPath)));
110110
return false;
111111
}
112112
Version? javaVersion;
113113
try {
114-
javaVersion = _java!.version;
114+
javaVersion = _java.version;
115115
} on Exception catch (error) {
116116
_logger.printTrace(error.toString());
117117
}
@@ -253,13 +253,13 @@ class AndroidLicenseValidator extends DoctorValidator {
253253
final List<ValidationMessage> messages = <ValidationMessage>[];
254254

255255
// Match pre-existing early termination behavior
256-
if (_androidSdk == null || _androidSdk?.latestVersion == null ||
257-
_androidSdk!.validateSdkWellFormed().isNotEmpty ||
256+
if (_androidSdk == null || _androidSdk.latestVersion == null ||
257+
_androidSdk.validateSdkWellFormed().isNotEmpty ||
258258
! await _checkJavaVersionNoOutput()) {
259259
return ValidationResult(ValidationType.missing, messages);
260260
}
261261

262-
final String sdkVersionText = _userMessages.androidStatusInfo(_androidSdk!.latestVersion!.buildToolsVersionName);
262+
final String sdkVersionText = _userMessages.androidStatusInfo(_androidSdk.latestVersion!.buildToolsVersionName);
263263

264264
// Check for licenses.
265265
switch (await licensesAccepted) {
@@ -371,7 +371,7 @@ class AndroidLicenseValidator extends DoctorValidator {
371371

372372
try {
373373
final Process process = await _processManager.start(
374-
<String>[_androidSdk!.sdkManagerPath!, '--licenses'],
374+
<String>[_androidSdk.sdkManagerPath!, '--licenses'],
375375
environment: _java?.environment,
376376
);
377377

@@ -404,15 +404,15 @@ class AndroidLicenseValidator extends DoctorValidator {
404404
final int exitCode = await process.exitCode;
405405
if (exitCode != 0) {
406406
throwToolExit(_userMessages.androidCannotRunSdkManager(
407-
_androidSdk?.sdkManagerPath ?? '',
407+
_androidSdk.sdkManagerPath ?? '',
408408
'exited code $exitCode',
409409
_platform,
410410
));
411411
}
412412
return true;
413413
} on ProcessException catch (e) {
414414
throwToolExit(_userMessages.androidCannotRunSdkManager(
415-
_androidSdk?.sdkManagerPath ?? '',
415+
_androidSdk.sdkManagerPath ?? '',
416416
e.toString(),
417417
_platform,
418418
));

packages/flutter_tools/lib/src/android/migrations/android_studio_java_gradle_conflict_migration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class AndroidStudioJavaGradleConflictMigration extends ProjectMigrator {
9191
return;
9292
}
9393

94-
if (_androidStudio == null || _androidStudio!.version == null) {
94+
if (_androidStudio == null || _androidStudio.version == null) {
9595
logger.printTrace(androidStudioNotFound);
9696
return;
97-
} else if (_androidStudio!.version!.major < androidStudioFlamingo.major) {
97+
} else if (_androidStudio.version!.major < androidStudioFlamingo.major) {
9898
logger.printTrace(androidStudioVersionBelowFlamingo);
9999
return;
100100
}

packages/flutter_tools/lib/src/base/context.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class AppContext {
116116
T? get<T>() {
117117
dynamic value = _generateIfNecessary(T, _overrides);
118118
if (value == null && _parent != null) {
119-
value = _parent!.get<T>();
119+
value = _parent.get<T>();
120120
}
121121
return _unboxNull(value ?? _generateIfNecessary(T, _fallbacks)) as T?;
122122
}

packages/flutter_tools/lib/src/cache.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class Cache {
558558
/// Return the top-level directory in the cache; this is `bin/cache`.
559559
Directory getRoot() {
560560
if (_rootOverride != null) {
561-
return _fileSystem.directory(_fileSystem.path.join(_rootOverride!.path, 'bin', 'cache'));
561+
return _fileSystem.directory(_fileSystem.path.join(_rootOverride.path, 'bin', 'cache'));
562562
} else {
563563
return _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin', 'cache'));
564564
}

packages/flutter_tools/lib/src/commands/attach.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
277277
logger: _logger,
278278
),
279279
notifyingLogger: (_logger is NotifyingLogger)
280-
? _logger as NotifyingLogger
280+
? _logger
281281
: NotifyingLogger(verbose: _logger.isVerbose, parent: _logger),
282282
logToStdout: true,
283283
)

packages/flutter_tools/lib/src/commands/update_packages.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ Directory createTemporaryFlutterSdk(
17531753
// Fill in SDK dependency constraint.
17541754
output.write('''
17551755
environment:
1756-
sdk: '>=3.0.0-0 <4.0.0'
1756+
sdk: '>=3.2.0-0 <4.0.0'
17571757
''');
17581758

17591759
output.writeln('dependencies:');
@@ -1785,7 +1785,7 @@ description: Dart SDK extensions for dart:ui
17851785
homepage: http://flutter.io
17861786
# sky_engine requires sdk_ext support in the analyzer which was added in 1.11.x
17871787
environment:
1788-
sdk: '>=3.0.0-0 <4.0.0'
1788+
sdk: '>=3.2.0-0 <4.0.0'
17891789
''');
17901790

17911791
return directory;

packages/flutter_tools/lib/src/device.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class DeviceDiscoverySupportFilter {
393393
if (_flutterProject == null) {
394394
return true;
395395
}
396-
return device.isSupportedForProject(_flutterProject!);
396+
return device.isSupportedForProject(_flutterProject);
397397
}
398398
}
399399

packages/flutter_tools/lib/src/ios/application_package.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class BuildableIOSApp extends IOSApp {
141141
// not a top-level output directory.
142142
// Specifying `build/ios/archive/Runner` will result in `build/ios/archive/Runner.xcarchive`.
143143
String get archiveBundlePath => globals.fs.path.join(getIosBuildDirectory(), 'archive',
144-
_hostAppBundleName == null ? 'Runner' : globals.fs.path.withoutExtension(_hostAppBundleName!));
144+
_hostAppBundleName == null ? 'Runner' : globals.fs.path.withoutExtension(_hostAppBundleName));
145145

146146
// The output xcarchive bundle path `build/ios/archive/Runner.xcarchive`.
147147
String get archiveBundleOutputPath =>
@@ -150,7 +150,7 @@ class BuildableIOSApp extends IOSApp {
150150
String get builtInfoPlistPathAfterArchive => globals.fs.path.join(archiveBundleOutputPath,
151151
'Products',
152152
'Applications',
153-
_hostAppBundleName == null ? 'Runner.app' : _hostAppBundleName!,
153+
_hostAppBundleName ?? 'Runner.app',
154154
'Info.plist');
155155

156156
String get projectAppIconDirName => _projectImageAssetDirName(_appIconAsset);

0 commit comments

Comments
 (0)