registerHost method

void registerHost(
  1. String hostName,
  2. void onUpdate()
)

Register a screen host with the manager

hostName - Unique identifier for this host onUpdate - Callback to trigger when this host's content changes

Implementation

void registerHost(String hostName, void Function() onUpdate) {
  _hostCallbacks[hostName] = onUpdate;
  if (!_screens.containsKey(hostName)) {
    _screens[hostName] = [];
  }

  // If there's already content for this host, trigger update immediately
  if (_screens[hostName]!.isNotEmpty) {
    if (kDebugMode) {
      print('📺 ScreenManager: Host "$hostName" registered with existing content, triggering update');
    }
    onUpdate();
  }

  if (kDebugMode) {
    print('📺 ScreenManager: Registered host "$hostName"');
  }
}