GameSessionController.withHookName constructor

GameSessionController.withHookName({
  1. RoyLifecycleCoordinator? lifecycle,
  2. required String hookName,
})

BUG-93 audit fix: use this constructor instead of the default one when a consumer app builds MORE THAN ONE GameSessionController against the SAME RoyLifecycleCoordinator (e.g. 2 different demo screens' independent sessions) — give each a distinct hookName. RoyLifecycleCoordinator.removeHook matches by name, not by instance, so 2 controllers sharing the default 'game-session' name would have EITHER one's onClose silently remove the OTHER's hook too.

Implementation

GameSessionController.withHookName({this.lifecycle, required this.hookName})
  : timelineCapacity = _defaultTimelineCapacity,
    allowedMetadataKeys = const {},
    _createStopwatch = Stopwatch.new {
  if (hookName.isEmpty) {
    throw ArgumentError.value(hookName, 'hookName', 'must not be empty');
  }
  _warnIfLifecycleMissing();
  _initTimeline();
}