setCurrentScreen method
Sets the current screen. This is the single source of truth for screen scoping — a PiP belongs to the screen named here when it opened, and ends when this reports a different one. That is the expected end of most PiP impressions, not an error path.
Deliberately not driven by route events. Routes and screens are not the same thing: dialogs, bottom sheets and the PiP's own back-sentinel are all routes the user never "navigates" through, and a host using nested navigators or an unnamed root has routes that carry no screen identity at all. Keying off this call means a PiP ends exactly when the host says the user changed screens, and never because a route happened to pop.
Implementation
void setCurrentScreen(String name) {
final screenName = name.trim();
final previousScreen = _currentScreen;
_currentScreen = screenName.isEmpty ? null : screenName;
if (screenName.isNotEmpty) _componentRegistry.recordPage(screenName);
_componentRegistry.attachPendingAnchors(_currentScreen);
_pipOrchestrator.onScreenChanged(_currentScreen);
_floaterStoryOrchestrator.onScreenChanged(_currentScreen);
_dismissNudgeForScreenExit(previousScreen);
final activeGuide = _guideOrchestrator.state;
if (previousScreen != _currentScreen && activeGuide != null) {
_guideManager.dismiss(reason: DismissReason.screenExit);
}
if (_activePlugin == null) {
_logDegradedWarning('setCurrentScreen("$name")');
return;
}
_activePlugin!.onScreenChanged(screenName);
_log.d('Screen forwarded to plugin (screen=$screenName)');
}