WebFController class

Mixed-in types

Constructors

WebFController({bool enableDebug = false, bool enableBlink = false, WebFBundle? bundle, WebFThread? runningThread, Color? background, double? viewportWidth, double? viewportHeight, LoadHandler? onLoad, LoadHandler? onDOMContentLoaded, LoadErrorHandler? onLoadError, OnControllerInit? onControllerInit, JSErrorHandler? onJSError, LCPHandler? onLCP, LCPHandler? onLCPFinal, FCPHandler? onFCP, FPHandler? onFP, ContentVerificationHandler? onLCPContentVerification, UriParser? uriParser, List<WebFBundle>? preloadedBundles, List<Cookie>? initialCookies, String? initialRoute, Map<String, dynamic>? initialState, RouteObserver<ModalRoute<void>>? routeObserver, Map<String, SubViewBuilder>? routes, bool resizeToAvoidBottomInsets = true, WebFNetworkOptions? networkOptions, List<Interceptor>? dioInterceptors, HttpLoggerOptions? httpLoggerOptions})

Properties

allRouteMetrics Map<String, RoutePerformanceMetrics>
Gets all route performance metrics
no setter
background Color?
The background color for viewport, default to transparent. This determines the background color of the WebF widget content area.
final
boldText bool
no setter
buildContextStack List<HybridRoutePageContext>
Get current attached buildContexts. Especially useful to detect how many hybrid route pages attached to the Flutter tree.
no setter
controlledInitCompleter Completer
getter/setter pair
controllerOnDOMContentLoadedCompleter Completer
getter/setter pair
controllerOnLoadCompleter Completer
getter/setter pair
controllerPreloadingCompleter Completer
getter/setter pair
controllerPreRenderingCompleter Completer
getter/setter pair
cookieManager CookieManager
Cookie manager that provides methods to manipulate cookies.
getter/setter pair
currentBuildContext HybridRoutePageContext?
no setter
currentLCPElement Element?
Gets the current LCP element if it's still connected to the DOM
no setter
darkModeOverride ↔ dynamic
getter/setter pair
dioInterceptors List<Interceptor>?
Additional Dio interceptors to install for this controller's Dio instance.
getter/setter pair
disposed bool
no setter
entrypoint WebFBundle?
no setter
evaluated bool
getter/setter pair
fcpReported bool
no setter
fcpTime double
no setter
fpReported bool
no setter
fpTime double
no setter
hashCode int
The hash code for this object.
no setterinherited
hasLoadingError bool
no setter
history HistoryModule
Access to the standard Web History API implementation.
no setter
httpLoggerOptions HttpLoggerOptions?
Options for HTTP logging (PrettyDioLogger) when Dio networking is used.
final
hybridHistory HybridHistoryModule
Access to WebF's hybrid history implementation that integrates with Flutter navigation.
no setter
initialCookies List<Cookie>?
The initial cookies to set for the JavaScript environment.
final
initialRoute String?
The default route path for the hybrid router in WebF.
getter/setter pair
initialState Map<String, dynamic>?
The default route state for the hybrid router in WebF.
getter/setter pair
isCanceled bool
getter/setter pair
isComplete bool
no setter
isDarkMode bool?
Whether the current UI mode is dark mode.
no setter
isDOMComplete bool
no setter
isFlutterAttached bool
no setter
isFontsLoading bool
Flag indicating whether fonts are currently being loaded.
getter/setter pair
javascriptChannel WebFJavaScriptChannel
Gets the JavaScript channel for this controller.
no setter
key UniqueKey
getter/setter pair
lastReportedLCPTime double
no setter
lcpFinalized bool
no setter
lcpInitialized bool
no setter
lcpReported bool
no setter
loadingError Object?
no setter
loadingState LoadingState
Get the loading state dumper for tracking lifecycle phases
no setter
mode WebFLoadingMode
The loading mode for WebF content.
getter/setter pair
module WebFModuleController
The module controller that manages JavaScript modules and features.
no setter
getter/setter pair
networkOptions WebFNetworkOptions?
Combined network options (cache + adapter) with per-platform overrides.
final
nextHistoryStack Queue<HistoryItem>
Queue of next history items for the standard Web History API implementation.
final
onControllerInit OnControllerInit?
Callback triggered after the controller is fully initialized but before content loading.
getter/setter pair
onDOMContentLoaded LoadHandler?
Callback triggered when the app's DOM and CSS have finished loading.
getter/setter pair
onFCP FCPHandler?
Callback triggered when the First Contentful Paint (FCP) occurs. FCP is a Core Web Vitals metric that measures the time from when the page starts loading to when any part of the page's content is rendered on the screen. The callback provides the FCP time in milliseconds since navigation start.
getter/setter pair
onFP FPHandler?
Callback triggered when the First Paint (FP) occurs. FP measures the time from when the page starts loading to when the browser renders anything visually different from what was on the screen before navigation. This includes non-default background colors, borders, box shadows, or any visible content. The callback provides the FP time in milliseconds since navigation start.
getter/setter pair
onJSError JSErrorHandler?
Callback triggered when a JavaScript error occurs during loading.
getter/setter pair
onJSLog JSLogHandler?
getter/setter pair
onLCP LCPHandler?
Callback triggered when the Largest Contentful Paint (LCP) occurs. LCP is a Core Web Vitals metric that measures loading performance. This callback may be called multiple times as larger content elements are rendered. The callback provides the LCP time in milliseconds since navigation start.
getter/setter pair
onLCPContentVerification ContentVerificationHandler?
Callback triggered when LCP is finalized and content verification is performed. This callback provides content information about what was actually rendered when LCP occurred.
getter/setter pair
onLCPFinal LCPHandler?
Callback triggered once when the Largest Contentful Paint (LCP) metric is finalized. This happens when user interaction occurs (click, tap, keyboard input) or when the page is hidden. The callback provides the final LCP time in milliseconds since navigation start.
getter/setter pair
onLoad LoadHandler?
Callback triggered when the app is fully loaded, including DOM, CSS, JavaScript, and images.
getter/setter pair
onLoadError LoadErrorHandler?
Callback triggered when a network error occurs during loading.
getter/setter pair
onRouteFCP RouteFCPHandler?
getter/setter pair
onRouteFP RouteFPHandler?
getter/setter pair
onRouteLCP RouteLCPHandler?
Route-aware callbacks for performance metrics These callbacks include the route path along with the timing information
getter/setter pair
onRouteLCPFinal RouteLCPHandler?
getter/setter pair
onTitleChanged TitleChangedHandler?
Callback triggered when the title of the document changes.
getter/setter pair
origin String
no setter
ownerFlutterView FlutterView?
no setter
paused bool
no setter
preloadedBundles List<WebFBundle>?
Remote resources (HTML, CSS, JavaScript, Images, and other content loadable via WebFBundle) that can be pre-loaded before WebF is mounted in Flutter.
final
preloadStatus PreloadingStatus
getter/setter pair
preRenderingStatus PreRenderingStatus
getter/setter pair
previousHistoryStack Queue<HistoryItem>
Queue of previous history items for the standard Web History API implementation.
final
resizeToAvoidBottomInsets bool
If true the content should size itself to avoid the onscreen keyboard whose height is defined by the ambient FlutterView's FlutterView.viewInsets bottom property.
final
rootBuildContext HybridRoutePageContext?
no setter
routeObserver RouteObserver<ModalRoute<void>>?
A Navigator observer that notifies RouteAwares of changes to the state of their route.
final
routes Map<String, SubViewBuilder>?
The routing table for the WebF hybrid router.
getter/setter pair
runningThread WebFThread?
Specify the running thread for your JavaScript codes. Default value: DedicatedThread();
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionStorage Map<String, String>
Storage for session data that implements the standard Web Storage API's sessionStorage.
final
state WebFState?
no setter
textScaler TextScaler
no setter
unfinishedPreloadResources int
getter/setter pair
uri Uri?
The current URI of the WebF content as a Uri object.
no setter
uriParser UriParser?
Parser for handling and potentially transforming URIs within WebF.
getter/setter pair
url String
The current URL of the WebF content.
no setter
view WebFViewController
The view controller that manages the visual rendering and DOM operations.
no setter
viewportHeight double?
The height of WebF Widget. Default: the value of max-height in constraints. This allows you to explicitly set the height of the WebF rendering area regardless of parent constraints.
final
viewportLayoutCompleter Completer
getter/setter pair
viewportSize Size?
no setter
viewportWidth double?
The width of WebF Widget. Default: the value of max-width in constraints. This allows you to explicitly set the width of the WebF rendering area regardless of parent constraints.
final

Methods

addPreloadedBundle(WebFBundle bundle) → void
Adds preloaded bundles to the controller.
attachToFlutter(BuildContext context) → void
Attaches the WebF controller to a Flutter BuildContext.
attachWebFState(WebFState state) → void
checkCompleted() → void
checkPreloadCompleted() → void
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
detachFromFlutter(BuildContext? context) → void
Detaches the WebF controller from the Flutter widget tree.
dispatchDOMContentLoadedEvent() → void
Dispatches the DOMContentLoaded event to the document and window.
dispatchWindowLoadEvent() → void
Dispatches the load event to the window.
dispatchWindowPreloadedEvent() → void
Dispatches the preloaded event to the window.
dispatchWindowPreRenderedEvent() → void
Dispatches the prerendered event to the window.
dispatchWindowResizeEvent() Future<void>
Dispatches the resize event to the window.
dispose() Future<void>
Disposes the WebF controller and all associated resources.
dumpLoadingState({LoadingStateDumpOptions? options}) LoadingStateDump
Dumps the loading state of the WebFController across its lifecycle.
dumpRenderObjectTree(String? routePath, {bool writeToFile = false, bool printToConsole = false}) Future<RenderObjectTreeDumpResult?>
evaluateEntrypoint({AnimationController? animationController}) Future<void>
executeEntrypoint({bool shouldResolve = true, bool shouldEvaluate = true, AnimationController? animationController}) Future<void>
finalizeLCP() → void
Finalizes LCP measurement when user interaction occurs. After this is called, no more LCP candidates will be reported.
flushPendingCallbacks() → void
getPreloadBundleFromUrl(String url) WebFBundle?
Retrieves a preloaded bundle that matches the given URL.
getResourceContent(String? url) String?
getRouteMetrics(String routePath) RoutePerformanceMetrics?
Gets performance metrics for a specific route
initializePerformanceTracking(DateTime startTime) → void
Initializes performance tracking by recording the navigation start time. Called when the viewport is first laid out.
load(WebFBundle bundle) Future<WebFController?>
Loads content from the provided WebFBundle.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyElementRemoved(Element element) → void
Called when an element is removed from the DOM. Checks if it was the current LCP element and resets tracking if so.
pause() → void
Pauses all timers, animations, and JavaScript execution.
popBuildContext({BuildContext? context, String? routePath}) → void
preload(WebFBundle bundle, {Size? viewportSize, Duration? timeout}) Future<void>
Preloads remote resources into memory and begins execution when the WebF widget is mounted into the Flutter tree. If the entrypoint is an HTML file, the HTML will be parsed, and its elements will be organized into a DOM tree. CSS files loaded through <style> and <link> elements will be parsed and the calculated styles applied to the corresponding DOM elements. However, JavaScript code will not be executed in this mode. If the entrypoint is a JavaScript file, WebF only do loading until the WebF widget is mounted into the Flutter tree. Using this mode can save up to 50% of loading time, while maintaining a high level of compatibility with the standard mode. It's safe and recommended to use this mode for all types of pages.
preRendering(WebFBundle bundle, {Duration? timeout}) Future<void>
The aggressive mode is a step further than preloading, cutting down up to 90% of loading time for optimal performance. This mode simulates the instantaneous response of native Flutter pages but may require modifications in the existing web codes for compatibility. In this mode, all remote resources are loaded and executed similarly to the standard mode, but with an offline-like behavior. Given that JavaScript is executed in this mode, properties like clientWidth and clientHeight from the viewModule always return 0. This is because no layout or paint processes occur during preRendering. If your application depends on viewModule properties, ensure that the related code is placed within the load and DOMContentLoaded or prerendered event callbacks of the window. These callbacks are triggered once the WebF widget is mounted into the Flutter tree. Apps optimized for this mode remain compatible with both standard and preloading modes. Aggressively preloads and prerenders content from the provided WebFBundle.
printDOMTree(String? routePath) → void
Prints the render object tree for debugging purposes.
printRenderObjectTree(String? routePath) Future<void>
Prints the render object tree for debugging purposes.
pushNewBuildContext({required BuildContext context, required String routePath, required Object? state}) → void
pushPendingCallbacks(PendingCallback callback) → void
reactiveWidgetElements() → void
reload() Future<WebFController?>
Reloads the current WebF content.
removeWebFState(WebFState state) → void
reportFCP() → void
Reports First Contentful Paint (FCP) when the first content is rendered. This should be called when the first text, image, SVG, or non-white canvas content is painted.
reportFP() → void
Reports First Paint (FP) when the first visual change is rendered. This includes any non-default background colors, borders, box shadows, or any visible content. FP always occurs before or at the same time as FCP.
reportLCPCandidate(Element element, double contentSize) → void
Reports a potential LCP candidate. @param element The element being reported as an LCP candidate @param contentSize The visible area of the element in pixels
resume() → void
Resumes all timers, animations, and JavaScript execution that were paused.
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
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
override
updateTextSettings({required TextScaler textScaler, required bool boldText}) → void
updateTextSettingsFromContext(BuildContext context) → void

Operators

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

Static Methods

fallbackBundleUri([double? id]) Uri
Creates a fallback URI for WebF bundle content.
getControllerMap() Map<double, WebFController?>
getControllerOfJSContextId(double? contextId) WebFController?