Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit 26690d3

Browse files
committed
Require Dart 3.2, update and fix lints
1 parent 24266ca commit 26690d3

21 files changed

+69
-68
lines changed

.github/workflows/test-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
matrix:
4848
# Add macos-latest and/or windows-latest if relevant for this package.
4949
os: [ubuntu-latest]
50-
sdk: [2.19.0, dev]
50+
sdk: [3.2, dev]
5151
steps:
5252
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
5353
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 2.12.0-wip
22

3-
- Require Dart 2.19
3+
- Require Dart 3.2
44

55
## 2.11.0
66

analysis_options.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# https://dart.dev/guides/language/analysis-options
1+
# https://dart.dev/tools/analysis#the-analysis-options-file
22
include: package:dart_flutter_team_lints/analysis_options.yaml
33

44
analyzer:
@@ -7,16 +7,15 @@ analyzer:
77
errors:
88
only_throw_errors: ignore
99
unawaited_futures: ignore
10+
inference_failure_on_instance_creation: ignore
11+
inference_failure_on_function_invocation: ignore
12+
inference_failure_on_collection_literal: ignore
1013

1114
linter:
1215
rules:
1316
- avoid_unused_constructor_parameters
14-
- comment_references
1517
- literal_only_boolean_expressions
1618
- missing_whitespace_between_adjacent_strings
1719
- no_adjacent_strings_in_list
1820
- no_runtimeType_toString
1921
- package_api_docs
20-
- prefer_relative_imports
21-
- test_types_in_equals
22-
- use_super_parameters

lib/src/subscription_stream.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class _CancelOnErrorSubscriptionWrapper<T>
7373
@override
7474
void onError(Function? handleError) {
7575
// Cancel when receiving an error.
76-
super.onError((error, StackTrace stackTrace) {
76+
super.onError((Object error, StackTrace stackTrace) {
7777
// Wait for the cancel to complete before sending the error event.
7878
super.cancel().whenComplete(() {
7979
if (handleError is ZoneBinaryCallback) {

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ description: Utility functions and classes related to the 'dart:async' library.
44
repository: https://github.com/dart-lang/async
55

66
environment:
7-
sdk: '>=2.19.0 <4.0.0'
7+
sdk: ^3.2.0
88

99
dependencies:
1010
collection: ^1.15.0
1111
meta: ^1.1.7
1212

1313
dev_dependencies:
14-
dart_flutter_team_lints: ^1.0.0
14+
dart_flutter_team_lints: ^2.0.0
1515
fake_async: ^1.2.0
1616
stack_trace: ^1.10.0
1717
test: ^1.16.0

test/async_cache_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void main() {
6060
Future<String> throwingCall() async => throw Exception();
6161
await expectLater(cache.fetch(throwingCall), throwsA(isException));
6262
// To let the timer invalidate the cache
63-
await Future.delayed(Duration(milliseconds: 5));
63+
await Future.delayed(const Duration(milliseconds: 5));
6464

6565
Future<String> call() async => 'Completed';
6666
expect(await cache.fetch(call), 'Completed', reason: 'Cache invalidates');

test/cancelable_operation_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ void main() {
574574
test('waits for chained cancellation', () async {
575575
var completer = CancelableCompleter<void>();
576576
var chainedOperation = completer.operation
577-
.then((_) => Future.delayed(Duration(milliseconds: 1)))
578-
.then((_) => Future.delayed(Duration(milliseconds: 1)));
577+
.then((_) => Future.delayed(const Duration(milliseconds: 1)))
578+
.then((_) => Future.delayed(const Duration(milliseconds: 1)));
579579

580580
await completer.operation.cancel();
581581
expect(completer.operation.isCanceled, true);

test/lazy_stream_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
var callbackCalled = false;
1515
var stream = LazyStream(expectAsync0(() {
1616
callbackCalled = true;
17-
return Stream.empty();
17+
return const Stream.empty();
1818
}));
1919

2020
await flushMicrotasks();
@@ -28,7 +28,7 @@ void main() {
2828
var callbackCalled = false;
2929
var stream = LazyStream(expectAsync0(() {
3030
callbackCalled = true;
31-
return Stream.empty();
31+
return const Stream.empty();
3232
}));
3333

3434
await flushMicrotasks();
@@ -95,7 +95,7 @@ void main() {
9595
late LazyStream stream;
9696
stream = LazyStream(expectAsync0(() {
9797
expect(() => stream.listen(null), throwsStateError);
98-
return Stream.empty();
98+
return const Stream.empty();
9999
}));
100100
stream.listen(null);
101101
});

test/null_stream_sink_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void main() {
5151

5252
expect(() => sink.add(1), throwsStateError);
5353
expect(() => sink.addError('oh no'), throwsStateError);
54-
expect(() => sink.addStream(Stream.empty()), throwsStateError);
54+
expect(() => sink.addStream(const Stream.empty()), throwsStateError);
5555
});
5656

5757
group('addStream', () {
@@ -93,15 +93,15 @@ void main() {
9393
test('causes events to throw StateErrors until the future completes',
9494
() async {
9595
var sink = NullStreamSink();
96-
var future = sink.addStream(Stream.empty());
96+
var future = sink.addStream(const Stream.empty());
9797
expect(() => sink.add(1), throwsStateError);
9898
expect(() => sink.addError('oh no'), throwsStateError);
99-
expect(() => sink.addStream(Stream.empty()), throwsStateError);
99+
expect(() => sink.addStream(const Stream.empty()), throwsStateError);
100100

101101
await future;
102102
sink.add(1);
103103
sink.addError('oh no');
104-
expect(sink.addStream(Stream.empty()), completes);
104+
expect(sink.addStream(const Stream.empty()), completes);
105105
});
106106
});
107107
});

test/reject_errors_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void main() {
171171

172172
test('throws on addStream()', () {
173173
var sink = controller.sink.rejectErrors()..close();
174-
expect(() => sink.addStream(Stream.empty()), throwsStateError);
174+
expect(() => sink.addStream(const Stream.empty()), throwsStateError);
175175
});
176176

177177
test('allows close()', () {
@@ -196,7 +196,7 @@ void main() {
196196
test('throws on addStream()', () {
197197
var sink = controller.sink.rejectErrors()
198198
..addStream(StreamController().stream);
199-
expect(() => sink.addStream(Stream.empty()), throwsStateError);
199+
expect(() => sink.addStream(const Stream.empty()), throwsStateError);
200200
});
201201

202202
test('throws on close()', () {

test/restartable_timer_test.dart

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,97 +10,98 @@ void main() {
1010
test('runs the callback once the duration has elapsed', () {
1111
FakeAsync().run((async) {
1212
var fired = false;
13-
RestartableTimer(Duration(seconds: 5), () {
13+
RestartableTimer(const Duration(seconds: 5), () {
1414
fired = true;
1515
});
1616

17-
async.elapse(Duration(seconds: 4));
17+
async.elapse(const Duration(seconds: 4));
1818
expect(fired, isFalse);
1919

20-
async.elapse(Duration(seconds: 1));
20+
async.elapse(const Duration(seconds: 1));
2121
expect(fired, isTrue);
2222
});
2323
});
2424

2525
test("doesn't run the callback if the timer is canceled", () {
2626
FakeAsync().run((async) {
2727
var fired = false;
28-
var timer = RestartableTimer(Duration(seconds: 5), () {
28+
var timer = RestartableTimer(const Duration(seconds: 5), () {
2929
fired = true;
3030
});
3131

32-
async.elapse(Duration(seconds: 4));
32+
async.elapse(const Duration(seconds: 4));
3333
expect(fired, isFalse);
3434
timer.cancel();
3535

36-
async.elapse(Duration(seconds: 4));
36+
async.elapse(const Duration(seconds: 4));
3737
expect(fired, isFalse);
3838
});
3939
});
4040

4141
test('resets the duration if the timer is reset before it fires', () {
4242
FakeAsync().run((async) {
4343
var fired = false;
44-
var timer = RestartableTimer(Duration(seconds: 5), () {
44+
var timer = RestartableTimer(const Duration(seconds: 5), () {
4545
fired = true;
4646
});
4747

48-
async.elapse(Duration(seconds: 4));
48+
async.elapse(const Duration(seconds: 4));
4949
expect(fired, isFalse);
5050
timer.reset();
5151

52-
async.elapse(Duration(seconds: 4));
52+
async.elapse(const Duration(seconds: 4));
5353
expect(fired, isFalse);
5454

55-
async.elapse(Duration(seconds: 1));
55+
async.elapse(const Duration(seconds: 1));
5656
expect(fired, isTrue);
5757
});
5858
});
5959

6060
test('re-runs the callback if the timer is reset after firing', () {
6161
FakeAsync().run((async) {
6262
var fired = 0;
63-
var timer = RestartableTimer(Duration(seconds: 5), () {
63+
var timer = RestartableTimer(const Duration(seconds: 5), () {
6464
fired++;
6565
});
6666

67-
async.elapse(Duration(seconds: 5));
67+
async.elapse(const Duration(seconds: 5));
6868
expect(fired, equals(1));
6969
timer.reset();
7070

71-
async.elapse(Duration(seconds: 5));
71+
async.elapse(const Duration(seconds: 5));
7272
expect(fired, equals(2));
7373
timer.reset();
7474

75-
async.elapse(Duration(seconds: 5));
75+
async.elapse(const Duration(seconds: 5));
7676
expect(fired, equals(3));
7777
});
7878
});
7979

8080
test('runs the callback if the timer is reset after being canceled', () {
8181
FakeAsync().run((async) {
8282
var fired = false;
83-
var timer = RestartableTimer(Duration(seconds: 5), () {
83+
var timer = RestartableTimer(const Duration(seconds: 5), () {
8484
fired = true;
8585
});
8686

87-
async.elapse(Duration(seconds: 4));
87+
async.elapse(const Duration(seconds: 4));
8888
expect(fired, isFalse);
8989
timer.cancel();
9090

91-
async.elapse(Duration(seconds: 4));
91+
async.elapse(const Duration(seconds: 4));
9292
expect(fired, isFalse);
9393
timer.reset();
9494

95-
async.elapse(Duration(seconds: 5));
95+
async.elapse(const Duration(seconds: 5));
9696
expect(fired, isTrue);
9797
});
9898
});
9999

100100
test("only runs the callback once if the timer isn't reset", () {
101101
FakeAsync().run((async) {
102-
RestartableTimer(Duration(seconds: 5), expectAsync0(() {}, count: 1));
103-
async.elapse(Duration(seconds: 10));
102+
RestartableTimer(
103+
const Duration(seconds: 5), expectAsync0(() {}, count: 1));
104+
async.elapse(const Duration(seconds: 10));
104105
});
105106
});
106107
}

test/result/result_captureAll_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void main() {
147147

148148
expect(all, completion(expected));
149149

150-
var completeFunctions = List<Function()>.generate(n, (i) {
150+
var completeFunctions = List<void Function()>.generate(n, (i) {
151151
var c = cs[i];
152152
return () =>
153153
throws(i) ? c.completeError('$i', someStack) : c.complete(i);

test/result/result_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void main() {
6161
var c = Completer<int>();
6262
c.future.then(expectAsync1((int v) {
6363
expect(v, equals(42));
64-
}), onError: (e, s) {
64+
}), onError: (Object? e, s) {
6565
fail('Unexpected error');
6666
});
6767
result.complete(c);
@@ -100,7 +100,7 @@ void main() {
100100
Result<int> result = ValueResult<int>(42);
101101
result.asFuture.then(expectAsync1((int v) {
102102
expect(v, equals(42));
103-
}), onError: (e, s) {
103+
}), onError: (Object? e, s) {
104104
fail('Unexpected error');
105105
});
106106
});
@@ -122,7 +122,7 @@ void main() {
122122
expect(result.isError, isFalse);
123123
var value = result.asValue!;
124124
expect(value.value, equals(42));
125-
}), onError: (e, s) {
125+
}), onError: (Object? e, s) {
126126
fail('Unexpected error: $e');
127127
});
128128
});
@@ -135,7 +135,7 @@ void main() {
135135
var error = result.asError!;
136136
expect(error.error, equals('BAD'));
137137
expect(error.stackTrace, same(stack));
138-
}), onError: (e, s) {
138+
}), onError: (Object? e, s) {
139139
fail('Unexpected error: $e');
140140
});
141141
});
@@ -144,7 +144,7 @@ void main() {
144144
var future = Future<Result<int>>.value(Result<int>.value(42));
145145
Result.release(future).then(expectAsync1((v) {
146146
expect(v, equals(42));
147-
}), onError: (e, s) {
147+
}), onError: (Object? e, s) {
148148
fail('Unexpected error: $e');
149149
});
150150
});
@@ -207,7 +207,7 @@ void main() {
207207
expect(v, equals(expected.asValue!.value));
208208
}
209209

210-
void errorListener(error, StackTrace stackTrace) {
210+
void errorListener(Object error, StackTrace stackTrace) {
211211
expect(expectedList.isEmpty, isFalse);
212212
Result expected = expectedList.removeFirst();
213213
expect(expected.isError, isTrue);
@@ -263,7 +263,7 @@ void main() {
263263
test('handle unary', () {
264264
var result = ErrorResult('error', stack);
265265
var called = false;
266-
result.handle((error) {
266+
result.handle((Object? error) {
267267
called = true;
268268
expect(error, 'error');
269269
});
@@ -273,7 +273,7 @@ void main() {
273273
test('handle binary', () {
274274
var result = ErrorResult('error', stack);
275275
var called = false;
276-
result.handle((error, stackTrace) {
276+
result.handle((Object? error, Object? stackTrace) {
277277
called = true;
278278
expect(error, 'error');
279279
expect(stackTrace, same(stack));
@@ -284,7 +284,7 @@ void main() {
284284
test('handle unary and binary', () {
285285
var result = ErrorResult('error', stack);
286286
var called = false;
287-
result.handle((error, [stackTrace]) {
287+
result.handle((Object? error, [Object? stackTrace]) {
288288
called = true;
289289
expect(error, 'error');
290290
expect(stackTrace, same(stack));
@@ -344,11 +344,11 @@ class TestSink<T> implements EventSink<T> {
344344
onDone();
345345
}
346346

347-
static void _nullData(value) {
347+
static void _nullData(dynamic value) {
348348
fail('Unexpected sink add: $value');
349349
}
350350

351-
static void _nullError(e, StackTrace s) {
351+
static void _nullError(dynamic e, StackTrace s) {
352352
fail('Unexpected sink addError: $e');
353353
}
354354

test/sink_base_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void main() {
328328
sink.flush();
329329
expect(() => sink.add([0]), throwsStateError);
330330
expect(() => sink.addError('oh no'), throwsStateError);
331-
expect(() => sink.addStream(Stream.empty()), throwsStateError);
331+
expect(() => sink.addStream(const Stream.empty()), throwsStateError);
332332
expect(() => sink.flush(), throwsStateError);
333333
expect(() => sink.close(), throwsStateError);
334334
});

0 commit comments

Comments
 (0)