addPopStateListener method

  1. @override
VoidCallback addPopStateListener(
  1. PopStateListener fn
)
override

Adds a listener to the popstate event and returns a function that, when invoked, removes the listener.

Implementation

@override
ui.VoidCallback addPopStateListener(PopStateListener fn) {
  void wrappedFn(Object event) {
    // `fn` expects `event.state`, not a `DomEvent`.
    fn((event as DomPopStateEvent).state);
  }
  _platformLocation.addPopStateListener(wrappedFn);
  return () => _platformLocation.removePopStateListener(wrappedFn);
}