lastOrNull method

Future<T?> lastOrNull()

Emits the stream's last value as a Future, or orElse if the stream closes empty.

Implementation

Future<T?> lastOrNull() async {
  T? last;
  await for (final value in this) {
    last = value;
  }
  return last;
}