diff --git a/pkgs/stream_channel/CHANGELOG.md b/pkgs/stream_channel/CHANGELOG.md index 30f7d32bc..9dd3990ec 100644 --- a/pkgs/stream_channel/CHANGELOG.md +++ b/pkgs/stream_channel/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.4 + +* Fix `StreamChannelMixin` so that it can be used as a mixin again. + ## 2.1.3 * Require Dart 3.3 diff --git a/pkgs/stream_channel/lib/stream_channel.dart b/pkgs/stream_channel/lib/stream_channel.dart index 85f9a9755..8e5309693 100644 --- a/pkgs/stream_channel/lib/stream_channel.dart +++ b/pkgs/stream_channel/lib/stream_channel.dart @@ -148,7 +148,7 @@ class _StreamChannel extends StreamChannelMixin { /// A mixin that implements the instance methods of [StreamChannel] in terms of /// [stream] and [sink]. -abstract class StreamChannelMixin implements StreamChannel { +abstract mixin class StreamChannelMixin implements StreamChannel { @override void pipe(StreamChannel other) { stream.pipe(other.sink); diff --git a/pkgs/stream_channel/pubspec.yaml b/pkgs/stream_channel/pubspec.yaml index eec8c1ba5..f050fca9c 100644 --- a/pkgs/stream_channel/pubspec.yaml +++ b/pkgs/stream_channel/pubspec.yaml @@ -1,5 +1,5 @@ name: stream_channel -version: 2.1.3 +version: 2.1.4 description: >- An abstraction for two-way communication channels based on the Dart Stream class. diff --git a/pkgs/stream_channel/test/stream_channel_test.dart b/pkgs/stream_channel/test/stream_channel_test.dart index c44b6ab6f..166671dd3 100644 --- a/pkgs/stream_channel/test/stream_channel_test.dart +++ b/pkgs/stream_channel/test/stream_channel_test.dart @@ -135,4 +135,46 @@ void main() { changed.sink.add(10); changed.sink.close(); }); + + group('StreamChannelMixin', () { + test('can be used as a mixin', () async { + var channel = StreamChannelMixinAsMixin(); + expect(channel.stream, emitsInOrder([1, 2, 3])); + channel.sink + ..add(1) + ..add(2) + ..add(3); + await channel.controller.close(); + }); + + test('can be extended', () async { + var channel = StreamChannelMixinAsSuperclass(); + expect(channel.stream, emitsInOrder([1, 2, 3])); + channel.sink + ..add(1) + ..add(2) + ..add(3); + await channel.controller.close(); + }); + }); +} + +class StreamChannelMixinAsMixin with StreamChannelMixin { + final controller = StreamController(); + + @override + StreamSink get sink => controller.sink; + + @override + Stream get stream => controller.stream; +} + +class StreamChannelMixinAsSuperclass extends StreamChannelMixin { + final controller = StreamController(); + + @override + StreamSink get sink => controller.sink; + + @override + Stream get stream => controller.stream; }