onTextLocatorChanged property

  1. @override
Stream<Locator> get onTextLocatorChanged
override

Fires whenever the Reader's current Locator changes.

The underlying event channel opts in to native-side buffering so the first event is never dropped even if it fires before the Dart onListen handshake completes (a race that can happen when the EPUB platform view initialises faster than the asynchronous channel setup).

Implementation

@override
Stream<Locator> get onTextLocatorChanged {
  _onTextLocatorChanged ??= textLocatorChannel
      .receiveBroadcastStream()
      .map((dynamic event) => Locator.fromJson(json.decode(event) as Map<String, dynamic>)!)
      .asBroadcastStream();
  return _onTextLocatorChanged!;
}