diff --git a/pkgs/async/.github/dependabot.yml b/pkgs/async/.github/dependabot.yml new file mode 100644 index 00000000..71cdeea3 --- /dev/null +++ b/pkgs/async/.github/dependabot.yml @@ -0,0 +1,10 @@ +# Set update schedule for GitHub Actions +# See https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot + +version: 2 +updates: + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/pkgs/async/.github/workflows/test-package.yml b/pkgs/async/.github/workflows/test-package.yml index fdddad8b..d257b9f9 100644 --- a/pkgs/async/.github/workflows/test-package.yml +++ b/pkgs/async/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install @@ -47,10 +47,10 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.14.1, dev] + sdk: [2.18.0, dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install diff --git a/pkgs/async/CHANGELOG.md b/pkgs/async/CHANGELOG.md index 6e2add92..1b3144ce 100644 --- a/pkgs/async/CHANGELOG.md +++ b/pkgs/async/CHANGELOG.md @@ -1,8 +1,9 @@ -## 2.10.0-dev +## 2.10.0 * Add `CancelableOperation.thenOperation` which gives more flexibility to complete the resulting operation. * Add `CancelableCompleter.completeOperation`. +* Require Dart 2.18 ## 2.9.0 diff --git a/pkgs/async/README.md b/pkgs/async/README.md index f7ed8beb..b25b7407 100644 --- a/pkgs/async/README.md +++ b/pkgs/async/README.md @@ -1,3 +1,7 @@ +[![Dart CI](https://github.com/dart-lang/async/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/async/actions/workflows/test-package.yml) +[![pub package](https://img.shields.io/pub/v/async.svg)](https://pub.dev/packages/async) +[![package publisher](https://img.shields.io/pub/publisher/async.svg)](https://pub.dev/packages/async/publisher) + Contains utility classes in the style of `dart:async` to work with asynchronous computations. diff --git a/pkgs/async/analysis_options.yaml b/pkgs/async/analysis_options.yaml index 5c781356..ca9be773 100644 --- a/pkgs/async/analysis_options.yaml +++ b/pkgs/async/analysis_options.yaml @@ -1,7 +1,30 @@ +# https://dart.dev/guides/language/analysis-options include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-casts: false - errors: - todo: ignore + language: + #strict-casts: true + #strict-inference: true + #strict-raw-types: true + +linter: + rules: + - always_declare_return_types + - avoid_dynamic_calls + - avoid_unused_constructor_parameters + - comment_references + - directives_ordering + - lines_longer_than_80_chars + - literal_only_boolean_expressions + - missing_whitespace_between_adjacent_strings + - no_adjacent_strings_in_list + - no_runtimeType_toString + - omit_local_variable_types + - package_api_docs + - prefer_relative_imports + - prefer_single_quotes + - test_types_in_equals + - throw_in_finally + - type_annotate_public_apis + - unnecessary_lambdas + - use_super_parameters diff --git a/pkgs/async/lib/async.dart b/pkgs/async/lib/async.dart index 10e7fe79..1d7b797c 100644 --- a/pkgs/async/lib/async.dart +++ b/pkgs/async/lib/async.dart @@ -2,7 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/// Utilities that expand on the asynchronous features of the `dart:async` library. +/// Utilities that expand on the asynchronous features of the `dart:async` +/// library. /// /// {@youtube 560 315 https://www.youtube.com/watch?v=r0tHiCjW2w0} library async; @@ -11,6 +12,7 @@ export 'src/async_cache.dart'; export 'src/async_memoizer.dart'; export 'src/byte_collector.dart'; export 'src/cancelable_operation.dart'; +export 'src/chunked_stream_reader.dart'; export 'src/delegate/event_sink.dart'; export 'src/delegate/future.dart'; export 'src/delegate/sink.dart'; @@ -22,9 +24,9 @@ export 'src/future_group.dart'; export 'src/lazy_stream.dart'; export 'src/null_stream_sink.dart'; export 'src/restartable_timer.dart'; -export 'src/result/result.dart'; export 'src/result/error.dart'; export 'src/result/future.dart'; +export 'src/result/result.dart'; export 'src/result/value.dart'; export 'src/single_subscription_transformer.dart'; export 'src/sink_base.dart'; @@ -41,4 +43,3 @@ export 'src/stream_subscription_transformer.dart'; export 'src/stream_zip.dart'; export 'src/subscription_stream.dart'; export 'src/typed_stream_transformer.dart'; -export 'src/chunked_stream_reader.dart'; diff --git a/pkgs/async/lib/src/async_cache.dart b/pkgs/async/lib/src/async_cache.dart index b0551823..6fc7cb0e 100644 --- a/pkgs/async/lib/src/async_cache.dart +++ b/pkgs/async/lib/src/async_cache.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:async/async.dart'; +import '../async.dart'; /// Runs asynchronous functions and caches the result for a period of time. /// @@ -21,9 +21,8 @@ import 'package:async/async.dart'; /// }); /// ``` /// -/// This class's timing can be mocked using [`fake_async`][fake_async]. -/// -/// [fake_async]: https://pub.dev/packages/fake_async +/// This class's timing can be mocked using +/// [`fake_async`](https://pub.dev/packages/fake_async). class AsyncCache { /// How long cached values stay fresh. /// @@ -80,7 +79,7 @@ class AsyncCache { /// /// Only starts counting time after the stream has been listened to, /// and it has completed with a `done` event. - @Deprecated("Feature will be removed") + @Deprecated('Feature will be removed') Stream fetchStream(Stream Function() callback) { if (_cachedValueFuture != null) { throw StateError('Previously used to cache via `fetch`'); diff --git a/pkgs/async/lib/src/cancelable_operation.dart b/pkgs/async/lib/src/cancelable_operation.dart index 65ecabc8..443ee78a 100644 --- a/pkgs/async/lib/src/cancelable_operation.dart +++ b/pkgs/async/lib/src/cancelable_operation.dart @@ -17,7 +17,8 @@ class CancelableOperation { CancelableOperation._(this._completer); - /// Creates a [CancelableOperation] with the same result as the [result] future. + /// Creates a [CancelableOperation] with the same result as the [result] + /// future. /// /// When this operation is canceled, [onCancel] will be called and any value /// or error later produced by [result] will be discarded. @@ -34,10 +35,11 @@ class CancelableOperation { /// Creates a [CancelableOperation] wrapping [subscription]. /// - /// This overrides [subscription.onDone] and [subscription.onError] so that - /// the returned operation will complete when the subscription completes or - /// emits an error. When this operation is canceled or when it emits an error, - /// the subscription will be canceled (unlike + /// This overrides [StreamSubscription.onDone] and + /// [StreamSubscription.onError] so that the returned operation will complete + /// when the subscription completes or emits an error. + /// When this operation is canceled or when it emits an error, the + /// subscription will be canceled (unlike /// `CancelableOperation.fromFuture(subscription.asFuture())`). static CancelableOperation fromSubscription( StreamSubscription subscription) { @@ -62,24 +64,24 @@ class CancelableOperation { Iterable> operations) { operations = operations.toList(); if (operations.isEmpty) { - throw ArgumentError("May not be empty", "operations"); + throw ArgumentError('May not be empty', 'operations'); } var done = false; // Note: if one or more of the completers have already completed, // they're not actually cancelled by this. - Future _cancelAll() { + Future cancelAll() { done = true; return Future.wait(operations.map((operation) => operation.cancel())); } - var completer = CancelableCompleter(onCancel: _cancelAll); + var completer = CancelableCompleter(onCancel: cancelAll); for (var operation in operations) { operation.then((value) { - if (!done) _cancelAll().whenComplete(() => completer.complete(value)); + if (!done) cancelAll().whenComplete(() => completer.complete(value)); }, onError: (error, stackTrace) { if (!done) { - _cancelAll() + cancelAll() .whenComplete(() => completer.completeError(error, stackTrace)); } }); @@ -266,7 +268,7 @@ class CancelableOperation { /// Cancels this operation. /// - /// If this operation [isComplete] or [isCanceled] this call is ignored. + /// If this operation [isCompleted] or [isCanceled] this call is ignored. /// Returns the result of the `onCancel` callback, if one exists. Future cancel() => _completer._cancel(); @@ -388,7 +390,7 @@ class CancelableCompleter { /// /// If [value] is a [Future] the [operation] will complete /// with the result of that `Future` once it is available. - /// In that case [isComplete] will be `true` before the [operation] + /// In that case [isCompleted] will be `true` before the [operation] /// is complete. /// /// If the type [T] is not nullable [value] may be not be omitted or `null`. @@ -426,7 +428,7 @@ class CancelableCompleter { /// canceled. void completeOperation(CancelableOperation result, {bool propagateCancel = true}) { - if (!_mayComplete) throw StateError("Already completed"); + if (!_mayComplete) throw StateError('Already completed'); _mayComplete = false; if (isCanceled) { if (propagateCancel) result.cancel(); diff --git a/pkgs/async/lib/src/chunked_stream_reader.dart b/pkgs/async/lib/src/chunked_stream_reader.dart index fd9be921..1d92216a 100644 --- a/pkgs/async/lib/src/chunked_stream_reader.dart +++ b/pkgs/async/lib/src/chunked_stream_reader.dart @@ -63,8 +63,8 @@ class ChunkedStreamReader { /// Whether a read request is currently being processed. /// /// Is `true` while a request is in progress. - /// While a read request, like [readChunk] or [readStream], is being processed, - /// no new requests can be made. + /// While a read request, like [readChunk] or [readStream], is being + /// processed, no new requests can be made. /// New read attempts will throw instead. bool _reading = false; diff --git a/pkgs/async/lib/src/delegate/event_sink.dart b/pkgs/async/lib/src/delegate/event_sink.dart index c011af5f..34c119b5 100644 --- a/pkgs/async/lib/src/delegate/event_sink.dart +++ b/pkgs/async/lib/src/delegate/event_sink.dart @@ -18,7 +18,7 @@ class DelegatingEventSink implements EventSink { /// Creates a wrapper that coerces the type of [sink]. /// - /// Unlike [new DelegatingEventSink], this only requires its argument to be an + /// Unlike [DelegatingEventSink.new], this only requires its argument to be an /// instance of `EventSink`, not `EventSink`. This means that calls to /// [add] may throw a [TypeError] if the argument type doesn't match the /// reified type of [sink]. @@ -33,7 +33,7 @@ class DelegatingEventSink implements EventSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { _sink.addError(error, stackTrace); } diff --git a/pkgs/async/lib/src/delegate/sink.dart b/pkgs/async/lib/src/delegate/sink.dart index e0b03c57..a1954f0d 100644 --- a/pkgs/async/lib/src/delegate/sink.dart +++ b/pkgs/async/lib/src/delegate/sink.dart @@ -16,7 +16,7 @@ class DelegatingSink implements Sink { /// Creates a wrapper that coerces the type of [sink]. /// - /// Unlike [new DelegatingSink], this only requires its argument to be an + /// Unlike [DelegatingSink.new], this only requires its argument to be an /// instance of `Sink`, not `Sink`. This means that calls to [add] may /// throw a [TypeError] if the argument type doesn't match the reified type of /// [sink]. diff --git a/pkgs/async/lib/src/delegate/stream.dart b/pkgs/async/lib/src/delegate/stream.dart index 6c2031a4..68992d5b 100644 --- a/pkgs/async/lib/src/delegate/stream.dart +++ b/pkgs/async/lib/src/delegate/stream.dart @@ -12,7 +12,7 @@ import 'dart:async'; /// Note that this is identical to [StreamView] in `dart:async`. It's provided /// under this name for consistency with other `Delegating*` classes. class DelegatingStream extends StreamView { - DelegatingStream(Stream stream) : super(stream); + DelegatingStream(super.stream); /// Creates a wrapper which throws if [stream]'s events aren't instances of /// `T`. diff --git a/pkgs/async/lib/src/delegate/stream_consumer.dart b/pkgs/async/lib/src/delegate/stream_consumer.dart index 0dad5ffa..c911c414 100644 --- a/pkgs/async/lib/src/delegate/stream_consumer.dart +++ b/pkgs/async/lib/src/delegate/stream_consumer.dart @@ -18,7 +18,7 @@ class DelegatingStreamConsumer implements StreamConsumer { /// Creates a wrapper that coerces the type of [consumer]. /// - /// Unlike [new StreamConsumer], this only requires its argument to be an + /// Unlike [StreamConsumer.new], this only requires its argument to be an /// instance of `StreamConsumer`, not `StreamConsumer`. This means that /// calls to [addStream] may throw a [TypeError] if the argument type doesn't /// match the reified type of [consumer]. diff --git a/pkgs/async/lib/src/delegate/stream_sink.dart b/pkgs/async/lib/src/delegate/stream_sink.dart index f18d501f..e6edd2ff 100644 --- a/pkgs/async/lib/src/delegate/stream_sink.dart +++ b/pkgs/async/lib/src/delegate/stream_sink.dart @@ -21,7 +21,7 @@ class DelegatingStreamSink implements StreamSink { /// Creates a wrapper that coerces the type of [sink]. /// - /// Unlike [new StreamSink], this only requires its argument to be an instance + /// Unlike [StreamSink.new], this only requires its argument to be an instance /// of `StreamSink`, not `StreamSink`. This means that calls to [add] may /// throw a [TypeError] if the argument type doesn't match the reified type of /// [sink]. @@ -36,7 +36,7 @@ class DelegatingStreamSink implements StreamSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { _sink.addError(error, stackTrace); } diff --git a/pkgs/async/lib/src/null_stream_sink.dart b/pkgs/async/lib/src/null_stream_sink.dart index 34b100bb..4d9bad0d 100644 --- a/pkgs/async/lib/src/null_stream_sink.dart +++ b/pkgs/async/lib/src/null_stream_sink.dart @@ -8,7 +8,7 @@ import 'dart:async'; /// /// The sink silently drops events until [close] is called, at which point it /// throws [StateError]s when events are added. This is the same behavior as a -/// sink whose remote end has closed, such as when a [WebSocket] connection has +/// sink whose remote end has closed, such as when a `WebSocket` connection has /// been closed. /// /// This can be used when a sink is needed but no events are actually intended @@ -41,8 +41,8 @@ class NullStreamSink implements StreamSink { /// Creates a null sink. /// - /// If [done] is passed, it's used as the [Sink.done] future. Otherwise, a - /// completed future is used. + /// If [done] is passed, it's used as the [StreamSink.done] future. Otherwise, + /// a completed future is used. NullStreamSink({Future? done}) : done = done ?? Future.value(); /// Creates a null sink whose [done] future emits [error]. diff --git a/pkgs/async/lib/src/restartable_timer.dart b/pkgs/async/lib/src/restartable_timer.dart index 9ecf4431..1cff458f 100644 --- a/pkgs/async/lib/src/restartable_timer.dart +++ b/pkgs/async/lib/src/restartable_timer.dart @@ -23,8 +23,8 @@ class RestartableTimer implements Timer { /// Creates a new timer. /// - /// The [callback] function is invoked after the given [duration]. Unlike a - /// normal non-periodic [Timer], [callback] may be called more than once. + /// The [_callback] function is invoked after the given [_duration]. Unlike a + /// normal non-periodic [Timer], [_callback] may be called more than once. RestartableTimer(this._duration, this._callback) : _timer = Timer(_duration, _callback); diff --git a/pkgs/async/lib/src/result/capture_transformer.dart b/pkgs/async/lib/src/result/capture_transformer.dart index 1f58d066..39aaef9f 100644 --- a/pkgs/async/lib/src/result/capture_transformer.dart +++ b/pkgs/async/lib/src/result/capture_transformer.dart @@ -4,8 +4,8 @@ import 'dart:async'; -import 'result.dart'; import 'capture_sink.dart'; +import 'result.dart'; /// A stream transformer that captures a stream of events into [Result]s. /// @@ -16,6 +16,5 @@ class CaptureStreamTransformer extends StreamTransformerBase> { @override Stream> bind(Stream source) => - Stream>.eventTransformed( - source, (sink) => CaptureSink(sink)); + Stream>.eventTransformed(source, CaptureSink.new); } diff --git a/pkgs/async/lib/src/result/error.dart b/pkgs/async/lib/src/result/error.dart index 9d0ba614..48f71b1d 100644 --- a/pkgs/async/lib/src/result/error.dart +++ b/pkgs/async/lib/src/result/error.dart @@ -50,7 +50,7 @@ class ErrorResult implements Result { if (errorHandler is ZoneBinaryCallback) { errorHandler(error, stackTrace); } else { - errorHandler(error); + (errorHandler as ZoneUnaryCallback)(error); } } diff --git a/pkgs/async/lib/src/result/release_transformer.dart b/pkgs/async/lib/src/result/release_transformer.dart index 2548ac9b..2f80d719 100644 --- a/pkgs/async/lib/src/result/release_transformer.dart +++ b/pkgs/async/lib/src/result/release_transformer.dart @@ -4,8 +4,8 @@ import 'dart:async'; -import 'result.dart'; import 'release_sink.dart'; +import 'result.dart'; /// A transformer that releases result events as data and error events. class ReleaseStreamTransformer extends StreamTransformerBase, T> { diff --git a/pkgs/async/lib/src/result/result.dart b/pkgs/async/lib/src/result/result.dart index 5f93b551..2de3902f 100644 --- a/pkgs/async/lib/src/result/result.dart +++ b/pkgs/async/lib/src/result/result.dart @@ -4,13 +4,13 @@ import 'dart:async'; +import '../stream_sink_transformer.dart'; import 'capture_sink.dart'; import 'capture_transformer.dart'; import 'error.dart'; import 'release_sink.dart'; import 'release_transformer.dart'; import 'value.dart'; -import '../stream_sink_transformer.dart'; /// The result of a computation. /// @@ -70,12 +70,12 @@ abstract class Result { /// Creates a `Result` holding a value. /// - /// Alias for [ValueResult.ValueResult]. + /// Alias for [ValueResult.new]. factory Result.value(T value) = ValueResult; /// Creates a `Result` holding an error. /// - /// Alias for [ErrorResult.ErrorResult]. + /// Alias for [ErrorResult.new]. factory Result.error(Object error, [StackTrace? stackTrace]) => ErrorResult(error, stackTrace); @@ -84,9 +84,7 @@ abstract class Result { /// The resulting future will never have an error. /// Errors have been converted to an [ErrorResult] value. static Future> capture(Future future) { - return future.then((value) => ValueResult(value), - onError: (Object error, StackTrace stackTrace) => - ErrorResult(error, stackTrace)); + return future.then(ValueResult.new, onError: ErrorResult.new); } /// Captures each future in [elements], @@ -139,7 +137,7 @@ abstract class Result { static Stream> captureStream(Stream source) => source.transform(CaptureStreamTransformer()); - /// Releases a stream of [result] values into a stream of the results. + /// Releases a stream of [source] values into a stream of the results. /// /// `Result` values of the source stream become value or error events in /// the returned stream as appropriate. diff --git a/pkgs/async/lib/src/result/value.dart b/pkgs/async/lib/src/result/value.dart index 7cfc4742..3872dd0b 100644 --- a/pkgs/async/lib/src/result/value.dart +++ b/pkgs/async/lib/src/result/value.dart @@ -4,8 +4,8 @@ import 'dart:async'; -import 'result.dart'; import 'error.dart'; +import 'result.dart'; /// A result representing a returned value. class ValueResult implements Result { diff --git a/pkgs/async/lib/src/sink_base.dart b/pkgs/async/lib/src/sink_base.dart index 62ca9810..f1d7d14b 100644 --- a/pkgs/async/lib/src/sink_base.dart +++ b/pkgs/async/lib/src/sink_base.dart @@ -9,7 +9,7 @@ import 'package:meta/meta.dart'; import 'async_memoizer.dart'; -/// An abstract class that implements [EventSink] in terms of [onData], +/// An abstract class that implements [EventSink] in terms of [onAdd], /// [onError], and [onClose] methods. /// /// This takes care of ensuring that events can't be added after [close] is @@ -57,11 +57,11 @@ abstract class EventSinkBase implements EventSink { } } -/// An abstract class that implements [StreamSink] in terms of [onData], +/// An abstract class that implements [StreamSink] in terms of [onAdd], /// [onError], and [onClose] methods. /// /// This takes care of ensuring that events can't be added after [close] is -/// called or during a call to [onStream]. +/// called or during a call to [addStream]. @Deprecated('Will be removed in the next major release') abstract class StreamSinkBase extends EventSinkBase implements StreamSink { @@ -97,23 +97,23 @@ abstract class StreamSinkBase extends EventSinkBase } } -/// An abstract class that implements `dart:io`'s [IOSink]'s API in terms of -/// [onData], [onError], [onClose], and [onFlush] methods. +/// An abstract class that implements `dart:io`'s `IOSink`'s API in terms of +/// [onAdd], [onError], [onClose], and [onFlush] methods. /// -/// Because [IOSink] is defined in `dart:io`, this can't officially implement +/// Because `IOSink` is defined in `dart:io`, this can't officially implement /// it. However, it's designed to match its API exactly so that subclasses can -/// implement [IOSink] without any additional modifications. +/// implement `IOSink` without any additional modifications. /// /// This takes care of ensuring that events can't be added after [close] is -/// called or during a call to [onStream]. +/// called or during a call to [addStream]. @Deprecated('Will be removed in the next major release') abstract class IOSinkBase extends StreamSinkBase> { - /// See [IOSink.encoding] from `dart:io`. + /// See `IOSink.encoding` from `dart:io`. Encoding encoding; IOSinkBase([this.encoding = utf8]); - /// See [IOSink.flush] from `dart:io`. + /// See `IOSink.flush` from `dart:io`. /// /// Because this base class doesn't do any buffering of its own, [flush] /// always completes immediately. @@ -137,14 +137,14 @@ abstract class IOSinkBase extends StreamSinkBase> { @visibleForOverriding Future onFlush(); - /// See [IOSink.write] from `dart:io`. + /// See [StringSink.write]. void write(Object? object) { var string = object.toString(); if (string.isEmpty) return; add(encoding.encode(string)); } - /// See [IOSink.writeAll] from `dart:io`. + /// See [StringSink.writeAll]. void writeAll(Iterable objects, [String separator = '']) { var first = true; for (var object in objects) { @@ -158,13 +158,13 @@ abstract class IOSinkBase extends StreamSinkBase> { } } - /// See [IOSink.writeln] from `dart:io`. + /// See [StringSink.writeln]. void writeln([Object? object = '']) { write(object); write('\n'); } - /// See [IOSink.writeCharCode] from `dart:io`. + /// See [StringSink.writeCharCode]. void writeCharCode(int charCode) { write(String.fromCharCode(charCode)); } diff --git a/pkgs/async/lib/src/stream_extensions.dart b/pkgs/async/lib/src/stream_extensions.dart index f8a180f5..13811e4c 100644 --- a/pkgs/async/lib/src/stream_extensions.dart +++ b/pkgs/async/lib/src/stream_extensions.dart @@ -6,10 +6,10 @@ import 'dart:async'; /// Utility extensions on [Stream]. extension StreamExtensions on Stream { - /// Creates a stream whose elements are contiguous slices of [this]. + /// Creates a stream whose elements are contiguous slices of `this`. /// /// Each slice is [length] elements long, except for the last one which may be - /// shorter if [this] emits too few elements. Each slice begins after the + /// shorter if `this` emits too few elements. Each slice begins after the /// last one ends. /// /// For example, `Stream.fromIterable([1, 2, 3, 4, 5]).slices(2)` emits diff --git a/pkgs/async/lib/src/stream_group.dart b/pkgs/async/lib/src/stream_group.dart index 514c3a4a..78912c9f 100644 --- a/pkgs/async/lib/src/stream_group.dart +++ b/pkgs/async/lib/src/stream_group.dart @@ -14,7 +14,7 @@ import 'package:collection/collection.dart'; /// this means that events emitted by broadcast streams will be dropped until /// [stream] has a listener.** /// -/// If the `StreamGroup` is constructed using [new StreamGroup], [stream] will +/// If the `StreamGroup` is constructed using [StreamGroup.new], [stream] will /// be single-subscription. In this case, if [stream] is paused or canceled, all /// streams in the group will likewise be paused or canceled, respectively. /// @@ -272,7 +272,7 @@ class StreamGroup implements Sink> { /// Starts actively forwarding events from [stream] to [_controller]. /// - /// This will pause the resulting subscription if [this] is paused. + /// This will pause the resulting subscription if `this` is paused. StreamSubscription _listenToStream(Stream stream) { var subscription = stream.listen(_controller.add, onError: _controller.addError, onDone: () => remove(stream)); diff --git a/pkgs/async/lib/src/stream_queue.dart b/pkgs/async/lib/src/stream_queue.dart index f9902b96..f7ab8bad 100644 --- a/pkgs/async/lib/src/stream_queue.dart +++ b/pkgs/async/lib/src/stream_queue.dart @@ -9,9 +9,9 @@ import 'package:collection/collection.dart'; import 'cancelable_operation.dart'; import 'result/result.dart'; -import 'subscription_stream.dart'; import 'stream_completer.dart'; import 'stream_splitter.dart'; +import 'subscription_stream.dart'; /// An asynchronous pull-based interface for accessing stream events. /// @@ -573,7 +573,7 @@ class StreamQueueTransaction { /// /// The parent queue's position is updated to be the same as [queue]'s. /// Further requests on all queues created by this transaction, including - /// [queue], will complete as though [cancel] were called with `immediate: + /// [queue], will complete as though `cancel` were called with `immediate: /// true`. /// /// Throws a [StateError] if [commit] or [reject] have already been called, or @@ -600,7 +600,7 @@ class StreamQueueTransaction { /// /// The parent will continue as though [StreamQueue.startTransaction] hadn't /// been called. Further requests on all queues created by this transaction - /// will complete as though [cancel] were called with `immediate: true`. + /// will complete as though `cancel` were called with `immediate: true`. /// /// Throws a [StateError] if [commit] or [reject] have already been called. void reject() { @@ -625,7 +625,7 @@ class StreamQueueTransaction { } } - /// Throws a [StateError] if [accept] or [reject] has already been called. + /// Throws a [StateError] if [commit] or [reject] has already been called. void _assertActive() { if (_committed) { throw StateError('This transaction has already been accepted.'); @@ -641,20 +641,20 @@ class StreamQueueTransaction { /// an `_EventRequest` object in the request queue. /// /// Events from the source stream are sent to the first request in the -/// queue until it reports itself as [isComplete]. +/// queue until it reports itself as `isComplete`. /// /// When the first request in the queue `isComplete`, either when becoming -/// the first request or after receiving an event, its [close] methods is +/// the first request or after receiving an event, its `close` methods is /// called. /// -/// The [close] method is also called immediately when the source stream +/// The `close` method is also called immediately when the source stream /// is done. abstract class _EventRequest { /// Handle available events. /// /// The available events are provided as a queue. The `update` function /// should only remove events from the front of the event queue, e.g., - /// using [removeFirst]. + /// using `removeFirst`. /// /// Returns `true` if the request is completed, or `false` if it needs /// more events. @@ -732,7 +732,7 @@ class _SkipRequest implements _EventRequest { /// Number of remaining events to skip. /// - /// The request [isComplete] when the values reaches zero. + /// The request `isComplete` when the values reaches zero. /// /// Decremented when an event is seen. /// Set to zero when an error is seen since errors abort the skip request. @@ -774,7 +774,7 @@ abstract class _ListRequest implements _EventRequest { /// Number of events to capture. /// - /// The request [isComplete] when the length of [_list] reaches + /// The request `isComplete` when the length of [_list] reaches /// this value. final int _eventsToTake; @@ -786,7 +786,7 @@ abstract class _ListRequest implements _EventRequest { /// Request for a [StreamQueue.take] call. class _TakeRequest extends _ListRequest { - _TakeRequest(int eventsToTake) : super(eventsToTake); + _TakeRequest(super.eventsToTake); @override bool update(QueueList> events, bool isDone) { @@ -810,7 +810,7 @@ class _TakeRequest extends _ListRequest { /// Request for a [StreamQueue.lookAhead] call. class _LookAheadRequest extends _ListRequest { - _LookAheadRequest(int eventsToTake) : super(eventsToTake); + _LookAheadRequest(super.eventsToTake); @override bool update(QueueList> events, bool isDone) { diff --git a/pkgs/async/lib/src/stream_sink_completer.dart b/pkgs/async/lib/src/stream_sink_completer.dart index 10e549d8..dc2f6df3 100644 --- a/pkgs/async/lib/src/stream_sink_completer.dart +++ b/pkgs/async/lib/src/stream_sink_completer.dart @@ -12,7 +12,8 @@ import 'null_stream_sink.dart'; /// until [setDestinationSink] is called, the events will be buffered. /// /// The same effect can be achieved by using a [StreamController] and adding it -/// to the sink using [Sink.addStream] when the destination sink is ready. This +/// to the sink using [StreamConsumer.addStream] when the destination sink is +/// ready. This /// class attempts to shortcut some of the overhead when possible. For example, /// if the [sink] only has events added after the destination sink has been set, /// those events are added directly to the sink. @@ -35,7 +36,7 @@ class StreamSinkCompleter { /// to the result of the future when the future completes. /// /// If the future completes with an error, the returned sink will instead - /// be closed. Its [Sink.done] future will contain the error. + /// be closed. Its [StreamSink.done] future will contain the error. static StreamSink fromFuture(Future> sinkFuture) { var completer = StreamSinkCompleter(); sinkFuture.then(completer.setDestinationSink, onError: completer.setError); @@ -64,7 +65,8 @@ class StreamSinkCompleter { _sink._setDestinationSink(destinationSink); } - /// Completes this to a closed sink whose [Sink.done] future emits [error]. + /// Completes this to a closed sink whose [StreamSink.done] future emits + /// [error]. /// /// This is useful when the process of loading the sink fails. /// @@ -118,7 +120,7 @@ class _CompleterSink implements StreamSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { if (_canSendDirectly) { _destinationSink!.addError(error, stackTrace); } else { diff --git a/pkgs/async/lib/src/stream_sink_extensions.dart b/pkgs/async/lib/src/stream_sink_extensions.dart index ed43341c..a82cfe1c 100644 --- a/pkgs/async/lib/src/stream_sink_extensions.dart +++ b/pkgs/async/lib/src/stream_sink_extensions.dart @@ -13,7 +13,7 @@ extension StreamSinkExtensions on StreamSink { StreamSink transform(StreamSinkTransformer transformer) => transformer.bind(this); - /// Returns a [StreamSink] that forwards to [this] but rejects errors. + /// Returns a [StreamSink] that forwards to `this` but rejects errors. /// /// If an error is passed (either by [addError] or [addStream]), the /// underlying sink will be closed and the error will be forwarded to the diff --git a/pkgs/async/lib/src/stream_sink_transformer.dart b/pkgs/async/lib/src/stream_sink_transformer.dart index d42d19ce..c1ed7478 100644 --- a/pkgs/async/lib/src/stream_sink_transformer.dart +++ b/pkgs/async/lib/src/stream_sink_transformer.dart @@ -53,7 +53,7 @@ abstract class StreamSinkTransformer { /// This means that calls to [StreamSink.add] on the returned sink may throw a /// [TypeError] if the argument type doesn't match the reified type of the /// sink. - @Deprecated("Will be removed in future version") + @Deprecated('Will be removed in future version') // TODO remove TypeSafeStreamSinkTransformer static StreamSinkTransformer typed( StreamSinkTransformer transformer) => diff --git a/pkgs/async/lib/src/stream_sink_transformer/handler_transformer.dart b/pkgs/async/lib/src/stream_sink_transformer/handler_transformer.dart index d6f188ec..496c7ca4 100644 --- a/pkgs/async/lib/src/stream_sink_transformer/handler_transformer.dart +++ b/pkgs/async/lib/src/stream_sink_transformer/handler_transformer.dart @@ -4,8 +4,8 @@ import 'dart:async'; -import '../stream_sink_transformer.dart'; import '../delegate/stream_sink.dart'; +import '../stream_sink_transformer.dart'; /// The type of the callback for handling data events. typedef HandleData = void Function(S data, EventSink sink); @@ -63,7 +63,7 @@ class _HandlerSink implements StreamSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { var handleError = _transformer._handleError; if (handleError == null) { _inner.addError(error, stackTrace); @@ -98,7 +98,7 @@ class _HandlerSink implements StreamSink { /// call [close], they don't leave any dangling [Future]s behind that might emit /// unhandleable errors. class _SafeCloseSink extends DelegatingStreamSink { - _SafeCloseSink(StreamSink inner) : super(inner); + _SafeCloseSink(super.inner); @override Future close() => super.close().catchError((_) {}); diff --git a/pkgs/async/lib/src/stream_sink_transformer/reject_errors.dart b/pkgs/async/lib/src/stream_sink_transformer/reject_errors.dart index 7e15d265..6d077f46 100644 --- a/pkgs/async/lib/src/stream_sink_transformer/reject_errors.dart +++ b/pkgs/async/lib/src/stream_sink_transformer/reject_errors.dart @@ -63,7 +63,7 @@ class RejectErrorsSink implements StreamSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { if (_closed) throw StateError('Cannot add event after closing.'); if (_inAddStream) { throw StateError('Cannot add event while adding stream.'); diff --git a/pkgs/async/lib/src/stream_sink_transformer/stream_transformer_wrapper.dart b/pkgs/async/lib/src/stream_sink_transformer/stream_transformer_wrapper.dart index 2afcbff8..b30e8ad7 100644 --- a/pkgs/async/lib/src/stream_sink_transformer/stream_transformer_wrapper.dart +++ b/pkgs/async/lib/src/stream_sink_transformer/stream_transformer_wrapper.dart @@ -50,7 +50,7 @@ class _StreamTransformerWrapperSink implements StreamSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { _controller.addError(error, stackTrace); } diff --git a/pkgs/async/lib/src/stream_zip.dart b/pkgs/async/lib/src/stream_zip.dart index 506bf6d9..f5b8296d 100644 --- a/pkgs/async/lib/src/stream_zip.dart +++ b/pkgs/async/lib/src/stream_zip.dart @@ -9,7 +9,7 @@ import 'dart:async'; /// This emits lists of collected values from each input stream. The first list /// contains the first value emitted by each stream, the second contains the /// second value, and so on. The lists have the same ordering as the iterable -/// passed to [new StreamZip]. +/// passed to [StreamZip.new]. /// /// Any errors from any of the streams are forwarded directly to this stream. class StreamZip extends Stream> { diff --git a/pkgs/async/lib/src/subscription_stream.dart b/pkgs/async/lib/src/subscription_stream.dart index 2c94e05d..6be88e30 100644 --- a/pkgs/async/lib/src/subscription_stream.dart +++ b/pkgs/async/lib/src/subscription_stream.dart @@ -68,8 +68,7 @@ class SubscriptionStream extends Stream { /// source subscription on the first error. class _CancelOnErrorSubscriptionWrapper extends DelegatingStreamSubscription { - _CancelOnErrorSubscriptionWrapper(StreamSubscription subscription) - : super(subscription); + _CancelOnErrorSubscriptionWrapper(super.subscription); @override void onError(Function? handleError) { @@ -80,7 +79,7 @@ class _CancelOnErrorSubscriptionWrapper if (handleError is ZoneBinaryCallback) { handleError(error, stackTrace); } else if (handleError != null) { - handleError(error); + (handleError as ZoneUnaryCallback)(error); } }); }); diff --git a/pkgs/async/pubspec.yaml b/pkgs/async/pubspec.yaml index cb6f348e..5ff1cb52 100644 --- a/pkgs/async/pubspec.yaml +++ b/pkgs/async/pubspec.yaml @@ -1,11 +1,11 @@ name: async -version: 2.10.0-dev +version: 2.10.0 description: Utility functions and classes related to the 'dart:async' library. repository: https://github.com/dart-lang/async environment: - sdk: ">=2.14.0 <3.0.0" + sdk: ">=2.18.0 <3.0.0" dependencies: collection: ^1.15.0 @@ -13,6 +13,6 @@ dependencies: dev_dependencies: fake_async: ^1.2.0 - lints: ^1.0.0 + lints: ^2.0.0 stack_trace: ^1.10.0 test: ^1.16.0 diff --git a/pkgs/async/test/async_cache_test.dart b/pkgs/async/test/async_cache_test.dart index 4948e530..77bda7c5 100644 --- a/pkgs/async/test/async_cache_test.dart +++ b/pkgs/async/test/async_cache_test.dart @@ -45,7 +45,7 @@ void main() { // No actual caching is done, just avoid duplicate requests. cache = AsyncCache.ephemeral(); - var fetched = cache.fetch(() async => "first"); + var fetched = cache.fetch(() async => 'first'); expect(fetched, completion('first')); expect( cache.fetch(expectAsync0(() async => fail('not called'), count: 0)), @@ -111,9 +111,7 @@ void main() { yield '3'; }).toList(); expect( - await cache - .fetchStream(expectAsync0(() => Stream.empty(), count: 0)) - .toList(), + await cache.fetchStream(expectAsync0(Stream.empty, count: 0)).toList(), ['1', '2', '3']); }); diff --git a/pkgs/async/test/byte_collection_test.dart b/pkgs/async/test/byte_collection_test.dart index 7f2ecc64..67f319b0 100644 --- a/pkgs/async/test/byte_collection_test.dart +++ b/pkgs/async/test/byte_collection_test.dart @@ -4,8 +4,8 @@ import 'dart:async'; -import 'package:test/test.dart'; import 'package:async/async.dart'; +import 'package:test/test.dart'; void main() { group('collectBytes', () { diff --git a/pkgs/async/test/cancelable_operation_test.dart b/pkgs/async/test/cancelable_operation_test.dart index f073e80f..63ba2c34 100644 --- a/pkgs/async/test/cancelable_operation_test.dart +++ b/pkgs/async/test/cancelable_operation_test.dart @@ -591,7 +591,7 @@ void main() { var called = false; onValue = expectAsync1((_) { called = true; - fail("onValue unreachable"); + fail('onValue unreachable'); }, count: 0); await runThen().cancel(); @@ -604,11 +604,11 @@ void main() { var called = false; onError = expectAsync2((_, __) { called = true; - fail("onError unreachable"); + fail('onError unreachable'); }, count: 0); await runThen().cancel(); - originalCompleter.completeError("Error", StackTrace.empty); + originalCompleter.completeError('Error', StackTrace.empty); await flushMicrotasks(); expect(called, false); }); @@ -617,7 +617,7 @@ void main() { var called = false; onCancel = expectAsync0(() { called = true; - fail("onCancel unreachable"); + fail('onCancel unreachable'); }, count: 0); await runThen().cancel(); @@ -844,7 +844,7 @@ void main() { onError = expectAsync3((_, __, ___) {}, count: 0); await runThenOperation().cancel(); - originalCompleter.completeError("Error", StackTrace.empty); + originalCompleter.completeError('Error', StackTrace.empty); }); test('onCancel callback not called after cancel', () async { @@ -893,11 +893,11 @@ void main() { }); test('throws the first error to complete', () { - completer1.completeError("error 1"); - completer2.completeError("error 2"); - completer3.completeError("error 3"); + completer1.completeError('error 1'); + completer2.completeError('error 2'); + completer3.completeError('error 3'); - expect(operation.value, throwsA("error 1")); + expect(operation.value, throwsA('error 1')); }); test('cancels any completers that haven\'t completed', () async { diff --git a/pkgs/async/test/chunked_stream_reader.dart b/pkgs/async/test/chunked_stream_reader.dart index d80cf837..b4dd4f0a 100644 --- a/pkgs/async/test/chunked_stream_reader.dart +++ b/pkgs/async/test/chunked_stream_reader.dart @@ -5,8 +5,8 @@ import 'dart:async'; import 'dart:typed_data'; -import 'package:test/test.dart'; import 'package:async/async.dart'; +import 'package:test/test.dart'; void main() { test('readChunk() chunk by chunk', () async { diff --git a/pkgs/async/test/io_sink_impl.dart b/pkgs/async/test/io_sink_impl.dart index 832eb715..8fbf1c51 100644 --- a/pkgs/async/test/io_sink_impl.dart +++ b/pkgs/async/test/io_sink_impl.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Deprecated("Tests deprecated functionality") +@Deprecated('Tests deprecated functionality') library io_sink_impl; import 'dart:io'; diff --git a/pkgs/async/test/lazy_stream_test.dart b/pkgs/async/test/lazy_stream_test.dart index 32c6b142..cde1928f 100644 --- a/pkgs/async/test/lazy_stream_test.dart +++ b/pkgs/async/test/lazy_stream_test.dart @@ -83,7 +83,7 @@ void main() { }); test("a lazy stream can't be listened to multiple times", () { - var stream = LazyStream(expectAsync0(() => Stream.empty())); + var stream = LazyStream(expectAsync0(Stream.empty)); expect(stream.isBroadcast, isFalse); stream.listen(null); diff --git a/pkgs/async/test/result/result_captureAll_test.dart b/pkgs/async/test/result/result_captureAll_test.dart index fb528360..25c57759 100644 --- a/pkgs/async/test/result/result_captureAll_test.dart +++ b/pkgs/async/test/result/result_captureAll_test.dart @@ -14,7 +14,7 @@ final someStack = StackTrace.current; Result res(int n) => Result.value(n); -Result err(n) => ErrorResult('$n', someStack); +Result err(int n) => ErrorResult('$n', someStack); /// Helper function creating an iterable of futures. Iterable> futures(int count, diff --git a/pkgs/async/test/result/result_flattenAll_test.dart b/pkgs/async/test/result/result_flattenAll_test.dart index 2521e9e2..0d2b9634 100644 --- a/pkgs/async/test/result/result_flattenAll_test.dart +++ b/pkgs/async/test/result/result_flattenAll_test.dart @@ -9,7 +9,7 @@ import 'package:test/test.dart'; final someStack = StackTrace.current; Result res(T n) => Result.value(n); -Result err(n) => ErrorResult('$n', someStack); +Result err(int n) => ErrorResult('$n', someStack); /// Helper function creating an iterable of results. Iterable> results(int count, diff --git a/pkgs/async/test/result/result_test.dart b/pkgs/async/test/result/result_test.dart index 154785ba..568a8910 100644 --- a/pkgs/async/test/result/result_test.dart +++ b/pkgs/async/test/result/result_test.dart @@ -335,7 +335,7 @@ class TestSink implements EventSink { } @override - void addError(error, [StackTrace? stack]) { + void addError(Object error, [StackTrace? stack]) { onError(error, stack ?? StackTrace.fromString('')); } diff --git a/pkgs/async/test/sink_base_test.dart b/pkgs/async/test/sink_base_test.dart index 33958dd0..1f453946 100644 --- a/pkgs/async/test/sink_base_test.dart +++ b/pkgs/async/test/sink_base_test.dart @@ -2,15 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Deprecated("Tests deprecated functionality") +@Deprecated('Tests deprecated functionality') library sink_base_test; import 'dart:async'; import 'dart:convert'; -import 'package:test/test.dart'; - import 'package:async/async.dart'; +import 'package:test/test.dart'; const int letterA = 0x41; @@ -313,15 +312,13 @@ void main() { }); test('does nothing after close() is called', () { - var sink = - _IOSink(onFlush: expectAsync0(() => Future.value(), count: 0)); + var sink = _IOSink(onFlush: expectAsync0(Future.value, count: 0)); expect(sink.close(), completes); expect(sink.flush(), completes); }); test("can't be called during addStream()", () { - var sink = - _IOSink(onFlush: expectAsync0(() => Future.value(), count: 0)); + var sink = _IOSink(onFlush: expectAsync0(Future.value, count: 0)); sink.addStream(StreamController>().stream); expect(() => sink.flush(), throwsStateError); }); @@ -385,7 +382,7 @@ class _IOSink extends IOSinkBase { : _onAdd = onAdd ?? ((_) {}), _onError = onError ?? ((_, [__]) {}), _onClose = onClose ?? (() {}), - _onFlush = onFlush ?? (() => Future.value()), + _onFlush = onFlush ?? (Future.value), super(encoding); @override diff --git a/pkgs/async/test/stream_completer_test.dart b/pkgs/async/test/stream_completer_test.dart index 5ccf44e0..eaeb7192 100644 --- a/pkgs/async/test/stream_completer_test.dart +++ b/pkgs/async/test/stream_completer_test.dart @@ -285,7 +285,7 @@ void main() { await flushMicrotasks(); expect(lastEvent, '2'); subscription.onData((value) => lastEvent = -value); - subscription.onError((value) => lastEvent = '${-value}'); + subscription.onError((value) => lastEvent = '${-(value as int)}'); controller.add(1); await flushMicrotasks(); expect(lastEvent, -1); diff --git a/pkgs/async/test/stream_group_test.dart b/pkgs/async/test/stream_group_test.dart index 256056e6..5c684f30 100644 --- a/pkgs/async/test/stream_group_test.dart +++ b/pkgs/async/test/stream_group_test.dart @@ -495,11 +495,11 @@ void main() { group('regardless of type', () { group('single-subscription', () { - regardlessOfType(() => StreamGroup()); + regardlessOfType(StreamGroup.new); }); group('broadcast', () { - regardlessOfType(() => StreamGroup.broadcast()); + regardlessOfType(StreamGroup.broadcast); }); }); diff --git a/pkgs/async/test/stream_queue_test.dart b/pkgs/async/test/stream_queue_test.dart index 1d45a8c2..626eb16d 100644 --- a/pkgs/async/test/stream_queue_test.dart +++ b/pkgs/async/test/stream_queue_test.dart @@ -1124,7 +1124,7 @@ void main() { // Test expecting [startIndex .. startIndex + 9] as events using // `next`. - void nextTest(startIndex) { + void nextTest(int startIndex) { for (var i = 0; i < 10; i++) { expect(events.next, completion(startIndex + i)); } @@ -1137,7 +1137,7 @@ void main() { // Test expecting [startIndex .. startIndex + 9] as events using // `take(10)`. - void takeTest(startIndex) { + void takeTest(int startIndex) { expect(events.take(10), completion(List.generate(10, (i) => startIndex + i))); } diff --git a/pkgs/async/test/subscription_stream_test.dart b/pkgs/async/test/subscription_stream_test.dart index 8be0572d..67c6c04b 100644 --- a/pkgs/async/test/subscription_stream_test.dart +++ b/pkgs/async/test/subscription_stream_test.dart @@ -21,7 +21,7 @@ void main() { test('subscription stream after two events', () async { var stream = createStream(); var skips = 0; - var completer = Completer(); + var completer = Completer>(); late StreamSubscription subscription; subscription = stream.listen((value) { ++skips; diff --git a/pkgs/async/test/utils.dart b/pkgs/async/test/utils.dart index b7e64e2f..2fa1b92c 100644 --- a/pkgs/async/test/utils.dart +++ b/pkgs/async/test/utils.dart @@ -21,7 +21,7 @@ OptionalArgAction unreachable(String name) => /// A matcher that runs a callback in its own zone and asserts that that zone /// emits an error that matches [matcher]. -Matcher throwsZoned(matcher) => predicate((void Function() callback) { +Matcher throwsZoned(Matcher matcher) => predicate((void Function() callback) { var firstError = true; runZonedGuarded( callback, @@ -48,7 +48,8 @@ final throwsTypeError = throwsA(TypeMatcher()); /// Can be used to test cases where a stream should not be used. class UnusableStream extends Stream { @override - StreamSubscription listen(onData, {onError, onDone, cancelOnError}) { + StreamSubscription listen(void Function(T event)? onData, + {Function? onError, void Function()? onDone, bool? cancelOnError}) { throw UnimplementedError('Gotcha!'); } } @@ -67,7 +68,7 @@ class CompleterStreamSink implements StreamSink { @override void add(T event) {} @override - void addError(error, [StackTrace? stackTrace]) {} + void addError(Object error, [StackTrace? stackTrace]) {} @override Future addStream(Stream stream) async {} @override @@ -103,7 +104,7 @@ class TestSink implements StreamSink { } @override - void addError(error, [StackTrace? stackTrace]) { + void addError(Object error, [StackTrace? stackTrace]) { results.add(Result.error(error, stackTrace)); }