Prefer void to null (#22977)

* Future<void> main

* Future<void>.delayed

* prefer_void_to_Null

* address review comments
This commit is contained in:
Alexandre Ardhuin
2018-10-16 22:03:06 +02:00
committed by GitHub
parent 5efe095895
commit 0fb84e96c7
139 changed files with 373 additions and 385 deletions

View File

@@ -300,7 +300,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
await binding.pump(duration, phase);
count += 1;
} while (binding.hasScheduledFrame);
}).then<int>((void _) => count);
}).then<int>((_) => count);
}
/// Runs a [callback] that performs real asynchronous work.

View File

@@ -23,23 +23,23 @@ void main() {
testWidgets('completes when matcher completes', (WidgetTester tester) async {
final Completer<void> completer = Completer<void>();
final Future<void> future = expectLater(null, FakeMatcher(completer));
String value;
future.then<void>((void _) {
value = '123';
String result;
future.then<void>((void value) {
result = '123';
});
test_package.expect(value, isNull);
test_package.expect(result, isNull);
completer.complete();
test_package.expect(value, isNull);
test_package.expect(result, isNull);
await future;
await tester.pump();
test_package.expect(value, '123');
test_package.expect(result, '123');
});
testWidgets('respects the skip flag', (WidgetTester tester) async {
final Completer<void> completer = Completer<void>();
final Future<void> future = expectLater(null, FakeMatcher(completer), skip: 'testing skip');
bool completed = false;
future.then<void>((void _) {
future.then<void>((_) {
completed = true;
});
test_package.expect(completed, isFalse);
@@ -625,7 +625,7 @@ class FakeMatcher extends AsyncMatcher {
@override
Future<String> matchAsync(dynamic object) {
return completer.future.then<String>((void _) {
return completer.future.then<String>((void value) {
return object?.toString();
});
}