void main() async { final stream = fn(); print('here'); print(await stream.first); print('done'); } Stream fn() async* { print('try'); try { while (true) { print('send message'); yield 1; await Future.delayed(Duration(seconds: 1)); } } finally { print('end'); } }