GameSessionController class
Single source of truth for a game's session lifecycle.
- Inheritance
-
- Object
- GetLifeCycle
- DisposableInterface
- GetxController
- GameSessionController
- Implemented types
Constructors
- GameSessionController({RoyLifecycleCoordinator? lifecycle})
- GameSessionController.withHookName({RoyLifecycleCoordinator? lifecycle, 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. -
GameSessionController.withTimeline({RoyLifecycleCoordinator? lifecycle, String hookName = 'game-session', int timelineCapacity = _defaultTimelineCapacity, Set<
String> allowedMetadataKeys = const {}, Stopwatch createStopwatch()?}) - ENH-96: adds a bounded, privacy-sanitized outcome timeline on top of events — a consumer that doesn't need per-run causal history (pause reasons, win/lose metadata, monotonic offsets) keeps using the default constructor/withHookName unchanged; events itself is untouched by this feature either way (every constructor keeps appending to it exactly as before).
Properties
-
allowedMetadataKeys
→ Set<
String> -
ENH-96: default-DENY allowlist for winWithMetadata/loseWithMetadata
— see GameSessionController.withTimeline's doc. Empty by default
(the 2 pre-ENH-96 constructors), meaning win/lose (which pass no
metadata anyway) and any metadata a caller passes are both recorded
with an empty sanitized map.
final
-
events
→ RxList<
GameSessionPhase> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
no setterinherited
- hookName → String
-
Name this controller registers/removes its lifecycle hook under via
lifecycle. See GameSessionController.withHookName's doc for why
this must be unique per RoyLifecycleCoordinator a consumer shares
across more than one controller instance.
final
- initialized → bool
-
Checks whether the controller has already been initialized.
no setterinherited
- isClosed → bool
-
Checks whether the controller has already been closed.
no setterinherited
- lifecycle → RoyLifecycleCoordinator?
-
final
- listeners → int
-
no setterinherited
-
onDelete
→ InternalFinalCallback<
void> -
Internal callback that starts the cycle of this controller.
finalinherited
-
onStart
→ InternalFinalCallback<
void> -
Called at the exact moment the widget is allocated in memory.
It uses an internal "callable" type, to avoid any @overrides in subclases.
This method should be internal and is required to define the
lifetime cycle of the subclass.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
snapshot
→ Rx<
GameSessionSnapshot> -
final
-
timeline
→ List<
GameSessionTimelineEntry> -
Every entry recorded so far, oldest first, capped at
timelineCapacity — see GameSessionController.withTimeline's doc.
no setter
- timelineCapacity → int
-
ENH-96: max entries timeline retains — oldest evicted first once
exceeded. Every constructor sets this (default
_defaultTimelineCapacityfor the 2 pre-ENH-96 constructors, same as if a consumer never looks at timeline at all).final
Methods
-
$configureLifeCycle(
) → void -
inherited
-
addListener(
GetStateUpdate listener) → Disposer -
Register a closure to be called when the object notifies its listeners.
inherited
-
addListenerId(
Object? key, GetStateUpdate listener) → Disposer -
inherited
-
dispose(
) → void -
inherited
-
disposeId(
Object id) → void -
To dispose an
idfrom future updates(), this ids are registered byGetBuilder()or similar, so is a way to unlink the state change with the Widget from the Controller.inherited -
exportTimeline(
) → GameSessionTimelineExport -
A full, privacy-safe snapshot of timeline ready to hand to
DiagnosticsExportBundle/a support ticket/a log line. -
lose(
) → SdkResult< GameSessionSnapshot> -
loseWithMetadata(
Map< String, Object?> metadata) → SdkResult<GameSessionSnapshot> -
ENH-96: same transition as lose, plus
metadatarecorded on the terminal GameSessionTimelineEntry after sanitization. -
markReady(
) → SdkResult< GameSessionSnapshot> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyChildrens(
) → void -
inherited
-
onClose(
) → void -
Called before onDelete method. onClose might be used to
dispose resources used by the controller. Like closing events,
or streams before the controller is destroyed.
Or dispose objects that can potentially create some memory leaks,
like TextEditingControllers, AnimationControllers.
Might be useful as well to persist some data on disk.
override
-
onInit(
) → void -
Called immediately after the widget is allocated in memory.
You might use this to initialize something for the controller.
override
-
onReady(
) → void -
Called 1 frame after onInit(). It is the perfect place to enter
navigation events, like snackbar, dialogs, or a new route, or
async request.
inherited
-
pause(
GamePauseReason reason) → SdkResult< GameSessionSnapshot> -
refresh(
) → void -
inherited
-
refreshGroup(
Object id) → void -
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies.
inherited
-
removeListenerId(
Object id, VoidCallback listener) → void -
inherited
-
restart(
) → SdkResult< GameSessionSnapshot> -
resume(
GamePauseReason reason) → SdkResult< GameSessionSnapshot> -
start(
) → SdkResult< GameSessionSnapshot> -
toString(
) → String -
A string representation of this object.
inherited
-
update(
[List< Object> ? ids, bool condition = true]) → void -
Rebuilds
GetBuildereach time you callupdate(); Can take a List ofids, that will only update the matchingGetBuilder( id: ),idscan be reused amongGetBuilderslike group tags. The update will only notify the Widgets, ifconditionis true.inherited -
win(
) → SdkResult< GameSessionSnapshot> -
winWithMetadata(
Map< String, Object?> metadata) → SdkResult<GameSessionSnapshot> -
ENH-96: same transition as win, plus
metadatarecorded on the terminal GameSessionTimelineEntry after sanitization (see_sanitizeMetadata's doc) — win itself just delegates here with an empty map, so its own behavior/signature is 100% unchanged.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- maybe → GameSessionController?
-
Gets the instance if already registered (safe to call from
game/widget tests).
no setter