useStream<T> function
The latest snapshot of stream, from initialData on: waiting once
the stream is listened to, active with each event it delivers, done
once it closes, and none while there is no stream; each event rebuilds
the element. A snapshot keeps the latest data or error until the next.
The stream is listened to from the first build that gives it on, the
stream of a later build instead once it is not the same, and is
cancelled when the element is unmounted. The snapshot of a stream left
for another is the last one's, not connected, with preserveState, or
the first one, from initialData, without.
The last line of a log as it arrives:
HookBuilder(
builder: (context) {
final last = useStream(logLines, initialData: '');
return Text(last.data ?? '');
},
)
Implementation
AsyncSnapshot<T> useStream<T>(
Stream<T>? stream, {
T? initialData,
bool preserveState = true,
}) => use(_StreamHook(stream, initialData, preserveState: preserveState));