lastOrNull method

Future<T?> lastOrNull()

Emits the stream's last value, or null if the stream closes empty.

Implementation

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