Google is committed to advancing racial equity for Black communities. See how.

stream method

*[<Null safety>](https://dart.dev/null-safety)*

Stream<bool> stream ()

Listen for focus state events on the host viewRef. When listening, users will get the current focus state, followed by any future focus states. The returned stream instance should be cancelled whenever users are done listening to prevent memory leaks.

See //sdk/fidl/fuchsia.ui.views/view_ref_focused.fidl for additional documentation on what certain focus state transitions mean.

Implementation

Stream<bool> stream() {
  late final StreamController<bool> controller;
  controller = StreamController<bool>(
    // ignore: unnecessary_lambdas
    onCancel: () => controller.close(),
  );
  isFocused().then((state) => controller
    ..add(state)
    ..addStream(_focusStateChanges));
  return controller.stream;
}