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);
_pipOrchestrator.onScreenChanged(name);
_floaterStoryOrchestrator.onScreenChanged(name);
final activeGuide = _guideOrchestrator.state;
final activeGuideConfig = activeGuide?.config;
if (previousScreen != _currentScreen &&
activeGuide != null &&
(!activeGuide.campaign.allowsScreen(_currentScreen) ||
activeGuideConfig is SpotlightGuideConfig &&
activeGuideConfig.steps.any(
(step) => step.anchorlessTarget != null,
))) {
_guideManager.dismiss();
}
if (_activePlugin == null) {
_logDegradedWarning('setCurrentScreen("$name")');
return;
}
_activePlugin!.forwardScreen(screenName);
_logIfVerbose('Screen forwarded to plugin: $screenName');
}