ModifiableSnapshotView.fromStream constructor
Implementation
ModifiableSnapshotView.fromStream(Stream<Snapshot> stream) {
StreamSubscription? subscription;
_snapshots.onListen = () {
subscription ??= stream.listen(_snapshots.add,
onError: _snapshots.addError, onDone: _snapshots.close);
subscription!.resume();
};
_snapshots.onCancel = () {
if (stream.isBroadcast) {
subscription!.cancel();
subscription = null;
} else {
subscription!.pause();
}
};
_snapshots.done.then((v) {
subscription?.cancel();
subscription = null;
});
}