import 'dart:async'; Stream contStream() async* { for (var k = 0; k < 10; k++) { yield k; } } Stream timedCounter() async* { int i = 0; while (true) { await Future.delayed(Duration(seconds: 1)); yield i++; if (i == 10) break; } } class Bloc { int _total = 0; int get total => _total; final _sc = StreamController(); Stream get stream => _sc.stream; incrementarTotal(){ _total++; _sc.add(_total); } fechar(){ _sc.close(); } } void main() { var b = Bloc(); print('Bloc'); b.incrementarTotal(); b.stream.listen((data) => print(data)); b.incrementarTotal(); //var k = timedCounter(); //toList Creates and adds all elements of this stream to the list in the order they arrive. //k.map((data) => print(data)).toList().whenComplete(() => print('done')); // k.listen( // (data) => print(data), // onDone: () => print('Fim'), // ); }