GameWebViewHost class

Hosts one skin in a transparent web view: loads the cached bundle with the skin CSP, wires the digia channel to GameBridgeSession, arms the load and ready timers, blocks navigation outside the bundle folder, and pushes viewport, device and lifecycle changes. Port of iOS GameWebViewHost.

The skin talks through window.digia.postMessage(str) (the digia channel exists only in this WebView, so an iframe inside a skin cannot drive the bridge); replies and pushes go through window.DigiaBridge.__receive(str) guarded by window.DigiaBridge&&, so nothing is evaluated into a page that has not defined the bridge. The natives additionally origin-lock the inbound side to the bundle origin; webview_flutter has no message-listener API, and the channel's same-document scope is the equivalent guarantee here.

Never throws from build: a failed load or a silent skin closes through onFailure.

Platform gaps (documented, not silent): webview_flutter exposes no DOM storage, file-access, mixed-content, text-zoom or long-press settings, so the host enforces the contract where the plugin lets it — no zoom, a transparent background, media playback without a user gesture, the CSP meta tag (which is also the subresource allow-list: webview_flutter has no request-interception hook), the selection lockdown script, navigation pinned to the bundle folder — and the WebView defaults cover the rest. Long-press consumption except in edits has no plugin hook either; the selection CSS suppresses the callout and menu surface instead. Remote inspection is debug-only through the host app (the plugin has no per-WebView flag). Render-process death has no plugin signal: it degrades to bundle_load_failed through the resource-error path, and GameCrashKillSwitch fails fast once the platform reports one.

Inheritance

Constructors

GameWebViewHost({Key? key, required GameURLPolicy policy, required String html, required GameBridge bridge, required GameBridgeSession createSession(void send(String json)), required String sdkVersion, required void onViewport(double width, double height, GameSafeArea safeArea, double keyboardInset), required void onDevice(GameDeviceInfo info), required VoidCallback onShown, required void onFailure(GameFailureReason reason), required void onUserClose(String json), required void onForeground(bool foreground), bool showMute = false, bool showClose = true, void onMuteChanged(bool muted)?})
const

Properties

bridge → GameBridge
final
createSession → GameBridgeSession Function(void send(String json))
Builds the session once the web view exists; send delivers one JSON message to the skin.
final
hashCode → int
The hash code for this object.
no setterinherited
html → String
The cached index.html, already decoded.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onDevice → void Function(GameDeviceInfo info)
Latest device facts, so the next init and haptics read them.
final
onFailure → void Function(GameFailureReason reason)
final
onForeground → void Function(bool foreground)
final
onMuteChanged → void Function(bool muted)?
Fires when the user toggles mute. Null when the parent does not care.
final
onShown → VoidCallback
The skin's first ready.
final
onUserClose → void Function(String json)
The host close button (user) or system back (back).
final
onViewport → void Function(double width, double height, GameSafeArea safeArea, double keyboardInset)
Latest viewport, so the next init carries it.
final
policy → GameURLPolicy
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sdkVersion → String
final
showClose → bool
Whether the native X shows; hiding it is opt-in. Port of Android/iOS showClose (absent=true).
final
showMute → bool
Whether the native mute button shows. When true the host draws a mute button 8pt left of the close button; its state lives in memory for this game only. Tapping pushes device with soundAllowed flipped.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<GameWebViewHost>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited