InAppWebViewPreloader class
Coordinates an opt-in headless-to-inline WebView handoff.
A preloader does not create a second WebView. It starts the supplied headlessWebView once and exposes the same keepAlive instance for the later InAppWebView attachment. This moves WebView/provider startup and the initial navigation before the route that displays the WebView.
Call prewarm before building an InAppWebView and pass this instance to
its preloader parameter:
final preloader = InAppWebViewPreloader(
headlessWebView: HeadlessInAppWebView(
initialUrlRequest: URLRequest(url: WebUri('https://example.com')),
),
);
await preloader.prewarm();
// Later, in the route that displays the WebView:
InAppWebView(preloader: preloader);
The prewarm operation makes the native WebView available and starts the
initial navigation. It does not wait for onLoadStop; configure that
callback on the supplied HeadlessInAppWebView or on the inline widget as
usual.
This helper is intended for native WebView platforms. Web support is limited by the platform's KeepAlive disposal capability.
Constructors
- InAppWebViewPreloader({required HeadlessInAppWebView headlessWebView, InAppWebViewKeepAlive? keepAlive})
- Creates a preloader around an existing HeadlessInAppWebView.
Properties
- controller → InAppWebViewController?
-
The controller exposed by the headless WebView, when available.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- headlessWebView → HeadlessInAppWebView
-
The headless WebView that will be started by prewarm.
final
- isDisposed → bool
-
Whether this preloader has begun disposal.
no setter
- isReady → bool
-
Whether the native headless WebView is ready to be attached.
no setter
- keepAlive → InAppWebViewKeepAlive
-
The ownership token used when the headless WebView is attached inline.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → Future< void> - Disposes the retained WebView exactly once.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prewarm(
) → Future< void> - Starts the native WebView exactly once for concurrent callers.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited