Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 61754b7

Browse files
authored
Drop checks for unsound null values (#189)
Towards #111 During the null safety migration it was possible for `StreamSubscription.cancel()` to return `null` in some cases. Now that this package is only used with sound null safe code it isn't possible for these nulls to flow through anymore so it is not necessary to filter for them.
1 parent 37075a0 commit 61754b7

File tree

5 files changed

+5
-22
lines changed

5 files changed

+5
-22
lines changed

lib/src/aggregate_sample.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ extension AggregateSample<T> on Stream<T> {
135135
} else {
136136
triggerSub!.pause();
137137
}
138-
// Handle opt-out nulls
139-
cancels.removeWhere((Object? f) => f == null);
140138
if (cancels.isEmpty) return null;
141139
return cancels.wait.then((_) => null);
142140
};

lib/src/async_expand.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ extension AsyncExpand<T> on Stream<T> {
7878
}
7979
controller.onCancel = () {
8080
if (subscriptions.isEmpty) return null;
81-
var cancels = [for (var s in subscriptions) s.cancel()]
82-
// Handle opt-out nulls
83-
..removeWhere((Object? f) => f == null);
84-
return cancels.wait.then((_) => null);
81+
return [for (var s in subscriptions) s.cancel()].wait.then((_) => null);
8582
};
8683
};
8784
return controller.stream;

lib/src/combine_latest.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ extension CombineLatest<T> on Stream<T> {
128128
var cancels = [
129129
sourceSubscription!.cancel(),
130130
otherSubscription!.cancel()
131-
]
132-
// Handle opt-out nulls
133-
..removeWhere((Object? f) => f == null);
131+
];
134132
sourceSubscription = null;
135133
otherSubscription = null;
136134
return cancels.wait.then((_) => null);
@@ -230,11 +228,7 @@ extension CombineLatest<T> on Stream<T> {
230228
}
231229
controller.onCancel = () {
232230
if (subscriptions.isEmpty) return null;
233-
var cancels = [for (var s in subscriptions) s.cancel()]
234-
// Handle opt-out nulls
235-
..removeWhere((Object? f) => f == null);
236-
if (cancels.isEmpty) return null;
237-
return cancels.wait.then((_) => null);
231+
return [for (var s in subscriptions) s.cancel()].wait.then((_) => null);
238232
};
239233
};
240234
return controller.stream;

lib/src/merge.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ extension Merge<T> on Stream<T> {
9090
}
9191
controller.onCancel = () {
9292
if (subscriptions.isEmpty) return null;
93-
var cancels = [for (var s in subscriptions) s.cancel()]
94-
// Handle opt-out nulls
95-
..removeWhere((Object? f) => f == null);
96-
if (cancels.isEmpty) return null;
97-
return cancels.wait.then((_) => null);
93+
return [for (var s in subscriptions) s.cancel()].wait.then((_) => null);
9894
};
9995
};
10096
return controller.stream;

lib/src/switch.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ extension SwitchLatest<T> on Stream<Stream<T>> {
124124
var cancels = [
125125
if (!outerStreamDone) outerSubscription.cancel(),
126126
if (sub != null) sub.cancel(),
127-
]
128-
// Handle opt-out nulls
129-
..removeWhere((Object? f) => f == null);
127+
];
130128
if (cancels.isEmpty) return null;
131129
return cancels.wait.then(_ignore);
132130
};

0 commit comments

Comments
 (0)