Future<String> futureTask() async {
await Future.delayed(const Duration(seconds: 5));
return 'Future complete';
}
final stream = Stream<String>.fromFuture(futureTask());
stream.listen(print,
onDone: () => print('Done'), onError: print);
// Outputs:
// "Future complete" after 'futureTask' finished.
// "Done" when stream completed.