listenable_stream 0.0.2 copy "listenable_stream: ^0.0.2" to clipboard
listenable_stream: ^0.0.2 copied to clipboard

outdated

Convert Listenable (eg. ChangeNotifier), ValueListenable(eg. ValueNotifier) to Stream / ValueStream.

listenable_stream #

  • Convert Flutter's Listenable (eg. ChangeNotifier) to Stream.
  • Convert Flutter's ValueListenable (eg. ValueNotifier) to ValueStream (incl. replay and not replay).

Pub Version codecov Flutter Tests

  • ListenableStream<Listenable>
  • ValueListenable<T>ValueStream<T>

Listenable.toStream() #

final ChangeNotifier changeNotifier = ChangeNotifier();
final Stream<ChangeNotifier> stream = changeNotifier.toStream();
stream.listen(print); // prints Instance of 'ChangeNotifier', Instance of 'ChangeNotifier'

changeNotifier.notifyListeners();
changeNotifier.notifyListeners();

ValueListenable.toValueStream() #

final ValueNotifier<int> valueNotifier = ValueNotifier(0);
final ValueStream<int> stream = valueNotifier.toValueStream();
stream.listen(print); // prints 1, 2

valueNotifier.value = 1;
valueNotifier.value = 2;
print(stream.value); // prints 2

ValueListenable.toValueStream(replay: true) #

final ValueNotifier<int> valueNotifier = ValueNotifier(0);
final ValueStream<int> stream = valueNotifier.toValueStream(replay: true);
stream.listen(print); // prints 0, 1, 2

valueNotifier.value = 1;
valueNotifier.value = 2;
print(stream.value); // prints 2
9
likes
30
pub points
85%
popularity

Publisher

unverified uploader

Convert Listenable (eg. ChangeNotifier), ValueListenable(eg. ValueNotifier) to Stream / ValueStream.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, rxdart

More

Packages that depend on listenable_stream