1
1
# listenable_stream
2
2
3
- - Convert Flutter's ` Listenable ` (eg . ` ChangeNotifier ` ) to ` Stream ` .
4
- - Convert Flutter's ` ValueListenable ` (eg. ` ValueNotifier ` ) to ` ValueStream ` (incl. replay and not replay).
3
+ - Convert Flutter's ` Listenable ` (e.g . ` ChangeNotifier ` ) to ` Stream ` .
4
+ - Convert Flutter's ` ValueListenable ` (e.g. ` ValueNotifier ` ) to ` ValueStream ` (incl. " replay" and " not replay" ).
5
5
6
6
[ ![ Pub Version] ( https://img.shields.io/pub/v/listenable_stream?include_prereleases )] ( https://pub.dev/packages/listenable_stream )
7
7
[ ![ codecov] ( https://codecov.io/gh/Flutter-Dart-Open-Source/listenable_stream/branch/master/graph/badge.svg?token=6eORcR6Web )] ( https://codecov.io/gh/Flutter-Dart-Open-Source/listenable_stream )
8
- [ ![ Flutter Tests] ( https://github.com/Flutter-Dart-Open-Source/listenable_stream/workflows/Flutter%20Tests/badge.svg )] ( https://github.com/Flutter-Dart-Open-Source/listenable_stream.git )
8
+ [ ![ Flutter Tests] ( https://github.com/Flutter-Dart-Open-Source/listenable_stream/actions/workflows/flutter.yml/badge.svg )] ( https://github.com/Flutter-Dart-Open-Source/listenable_stream/actions/workflows/flutter.yml )
9
+ [ ![ GitHub] ( https://img.shields.io/github/license/hoc081098/flutter_bloc_pattern?color=4EB1BA )] ( https://opensource.org/licenses/MIT )
10
+ [ ![ Style] ( https://img.shields.io/badge/style-lints-40c4ff.svg )] ( https://pub.dev/packages/lints )
11
+ [ ![ Hits] ( https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FFlutter-Dart-Open-Source%2Flistenable_stream&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false )] ( https://hits.seeyoufarm.com )
9
12
10
13
- [x] ` Listenable ` ▶ ` Stream<Listenable> `
11
14
- [x] ` ValueListenable<T> ` ▶ ` ValueStream<T> `
12
15
13
16
## Usage
14
17
15
18
### Listenable.toStream()
19
+
16
20
``` dart
17
21
final ChangeNotifier changeNotifier = ChangeNotifier();
18
22
final Stream<ChangeNotifier> stream = changeNotifier.toStream();
@@ -23,6 +27,7 @@ changeNotifier.notifyListeners();
23
27
```
24
28
25
29
### ValueListenable.toValueStream()
30
+
26
31
``` dart
27
32
final ValueNotifier<int> valueNotifier = ValueNotifier(0);
28
33
final ValueListenableStream<int> stream = valueNotifier.toValueStream();
@@ -34,6 +39,7 @@ print(stream.value); // prints 2
34
39
```
35
40
36
41
### ValueListenable.toValueStream(replayValue: true)
42
+
37
43
``` dart
38
44
final ValueNotifier<int> valueNotifier = ValueNotifier(0);
39
45
final ValueListenableStream<int> stream = valueNotifier.toValueStream(replayValue: true);
0 commit comments