prefer_is_empty and prefer_is_not_empty (#8474)

This commit is contained in:
Alexandre Ardhuin
2017-03-02 07:17:30 +01:00
committed by Adam Barth
parent 2f002885cc
commit 69b6bb87d1
12 changed files with 20 additions and 20 deletions

View File

@@ -775,7 +775,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
/// * [removeScopedWillPopCallback], which removes a callback.
@protected
bool get hasScopedWillPopCallback {
return _scopeKey.currentState == null || _scopeKey.currentState._willPopCallbacks.length > 0;
return _scopeKey.currentState == null || _scopeKey.currentState._willPopCallbacks.isNotEmpty;
}
@override

View File

@@ -408,7 +408,7 @@ class FlutterDriver {
/// Starts recording performance traces.
Future<Null> startTracing({List<TimelineStream> streams: _defaultStreams}) async {
assert(streams != null && streams.length > 0);
assert(streams != null && streams.isNotEmpty);
try {
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, <String, String>{
'recordedStreams': _timelineStreamsToString(streams)

View File

@@ -264,7 +264,7 @@ class _Renderer implements md.NodeVisitor {
_listIndents.removeLast();
if (_isBlockTag(element.tag)) {
if (_currentBlock.stack.length > 0) {
if (_currentBlock.stack.isNotEmpty) {
_MarkdownNodeList stackList = _currentBlock.stack.first;
_currentBlock.stack = stackList.list;
_currentBlock.open = false;
@@ -358,7 +358,7 @@ class _Block {
bool get open => _open;
set open(bool open) {
_open = open;
if (!open && subBlocks.length > 0)
if (!open && subBlocks.isNotEmpty)
subBlocks.last.isLast = true;
}
@@ -376,7 +376,7 @@ class _Block {
Widget contents;
if (subBlocks.length > 0) {
if (subBlocks.isNotEmpty) {
List<Widget> subWidgets = <Widget>[];
for (_Block subBlock in subBlocks) {
subWidgets.add(subBlock.build(context));
@@ -390,7 +390,7 @@ class _Block {
TextSpan span = _stackToTextSpan(new _MarkdownNodeList(stack));
contents = new RichText(text: span);
if (listIndents.length > 0) {
if (listIndents.isNotEmpty) {
Widget bullet;
if (listIndents.last == 'ul') {
bullet = new Text(
@@ -479,7 +479,7 @@ class _Block {
Widget _buildImage(BuildContext context, String src) {
List<String> parts = src.split('#');
if (parts.length == 0) return new Container();
if (parts.isEmpty) return new Container();
String path = parts.first;
double width;

View File

@@ -247,7 +247,7 @@ class _DevFSHttpWriter {
void _scheduleWrites(DevFSProgressReporter progressReporter) {
while (_inFlight < kMaxInFlight) {
if (_outstanding.length == 0) {
if (_outstanding.isEmpty) {
// Finished.
break;
}
@@ -289,7 +289,7 @@ class _DevFSHttpWriter {
progressReporter(_done, _max);
}
_inFlight--;
if ((_outstanding.length == 0) && (_inFlight == 0)) {
if ((_outstanding.isEmpty) && (_inFlight == 0)) {
_completer.complete(null);
} else {
_scheduleWrites(progressReporter);
@@ -411,7 +411,7 @@ class DevFS {
assetPathsToEvict.add(archivePath);
}
});
if (dirtyEntries.length > 0) {
if (dirtyEntries.isNotEmpty) {
printTrace('Updating files');
if (_httpWriter != null) {
try {

View File

@@ -251,7 +251,7 @@ class IOSDevice extends Device {
'--justlaunch',
];
if (launchArguments.length > 0) {
if (launchArguments.isNotEmpty) {
launchCommand.add('--args');
launchCommand.add('${launchArguments.join(" ")}');
}

View File

@@ -329,7 +329,7 @@ Directory _newTempDir() {
}
void _cleanupTempDirs() {
while (_tempDirs.length > 0) {
while (_tempDirs.isNotEmpty) {
_tempDirs.removeLast().deleteSync(recursive: true);
}
}