didPop method

  1. @override
void didPop(
  1. Route route,
  2. Route? previousRoute
)
override

Going back is a screen change too.

Without this, the current screen only ever moved forward: pushing /checkout reported it, but popping back to /home reported nothing, so screen-scoped state stayed pinned to a screen the user had already left.

This reports the revealed screen through SDKInstance.setCurrentScreen like every other hook here — a name, never a bare "something popped" signal. Screen scoping is defined entirely by the name last set, so a pop that reveals nothing nameable reports nothing: dialogs, bottom sheets and the PiP's own back-sentinel all pop without the user going anywhere, and a pop to an unnamed root leaves no screen to name. Hosts whose real screens carry no route name should call Digia.setCurrentScreen directly.

Implementation

@override
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
  _ensureAttached();
  if (_extractName(route) == null) return;

  final revealed = previousRoute != null ? _extractName(previousRoute) : null;
  if (revealed != null) {
    SDKInstance.instance.setCurrentScreen(revealed);
  }
}