use null aware operators (#32711)

* use null aware operators

* rollback changes about null-aware operator

* disable lint prefer_is_not_empty
This commit is contained in:
Alexandre Ardhuin
2019-05-16 22:25:51 +02:00
committed by GitHub
parent 3c16cf6a74
commit 4fa32df141
17 changed files with 31 additions and 39 deletions

View File

@@ -46,6 +46,5 @@ class Config {
String _userHomeDir() {
final String envKey = platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
final String value = platform.environment[envKey];
return value == null ? '.' : value;
return platform.environment[envKey] ?? '.';
}

View File

@@ -288,7 +288,7 @@ class IOSSimulator extends Device {
if (isSupported())
return 'Supported';
return _supportMessage != null ? _supportMessage : 'Unknown';
return _supportMessage ?? 'Unknown';
}
@override

View File

@@ -8,7 +8,7 @@ import 'watcher.dart';
/// Prints JSON events when running a test in --machine mode.
class EventPrinter extends TestWatcher {
EventPrinter({StringSink out}) : _out = out == null ? stdout: out;
EventPrinter({StringSink out}) : _out = out ?? stdout;
final StringSink _out;

View File

@@ -105,7 +105,7 @@ class FlutterVersion {
@override
String toString() {
final String versionText = frameworkVersion == 'unknown' ? '' : ' $frameworkVersion';
final String flutterText = 'Flutter$versionText • channel $channel • ${repositoryUrl == null ? 'unknown source' : repositoryUrl}';
final String flutterText = 'Flutter$versionText • channel $channel • ${repositoryUrl ?? 'unknown source'}';
final String frameworkText = 'Framework • revision $frameworkRevisionShort ($frameworkAge) • $frameworkCommitDate';
final String engineText = 'Engine • revision $engineRevisionShort';
final String toolsText = 'Tools • Dart $dartSdkVersion';

View File

@@ -718,13 +718,11 @@ class VM extends ServiceObjectOwner {
/// The number of bytes allocated (e.g. by malloc) in the native heap.
int _heapAllocatedMemoryUsage;
int get heapAllocatedMemoryUsage {
return _heapAllocatedMemoryUsage == null ? 0 : _heapAllocatedMemoryUsage;
}
int get heapAllocatedMemoryUsage => _heapAllocatedMemoryUsage ?? 0;
/// The peak resident set size for the process.
int _maxRSS;
int get maxRSS => _maxRSS == null ? 0 : _maxRSS;
int get maxRSS => _maxRSS ?? 0;
// The embedder's name, Flutter or dart_runner.
String _embedder;

View File

@@ -121,7 +121,7 @@ void testUsingContext(
},
);
});
}, timeout: timeout != null ? timeout : const Timeout(Duration(seconds: 60)),
}, timeout: timeout ?? const Timeout(Duration(seconds: 60)),
testOn: testOn, skip: skip);
}