WebFControllerManager class
A manager class that holds multiple WebFController instances.
It manages the lifecycle of controllers and enforces resource limits to prevent memory leaks while providing efficient controller reuse. Key features include:
- Caching and reusing controllers by name
- Automatic recreation of disposed controllers when needed
- Limiting the number of active and attached controllers
- Handling concurrent requests for the same controller
- Supporting preloading and prerendering for optimal performance
Properties
- attachedControllersCount → int
-
Gets the count of currently attached controllers.
no setter
- config → WebFControllerManagerConfig
-
Retrieves the current configuration of the manager
no setter
- controllerCount → int
-
Gets the total number of controllers currently managed
no setter
-
controllerNames
→ List<
String> -
Gets a list of all controller names currently registered with the manager
no setter
- detachedControllersCount → int
-
Gets the count of currently detached controllers.
no setter
- devToolsUrl → String?
-
Gets the DevTools server URL if running
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDevToolsEnabled → bool
-
Gets whether DevTools is currently enabled
no setter
-
routes
→ Map<
String, WidgetBuilder> -
Gets all registered route configurations from all controllers.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- useDioForNetwork → bool
-
Whether Dio-backed networking is enabled globally.
no setter
Methods
-
addOrUpdateControllerWithLoading(
{required String name, ControllerFactory? createController, required WebFBundle bundle, required WebFLoadingMode mode, Duration? timeout, Map< String, SubViewBuilder> ? routes, ControllerSetup? setup, bool forceReplace = false}) → Future<WebFController?> - Unified method to add or update a controller with preloading or prerendering.
-
addWithPreload(
{required String name, required ControllerFactory createController, required WebFBundle bundle, Duration? timeout, Map< String, SubViewBuilder> ? routes, ControllerSetup? setup}) → Future<WebFController?> - Adds a new controller with preloading enabled.
-
addWithPrerendering(
{required String name, required ControllerFactory createController, required WebFBundle bundle, Duration? timeout, Map< String, SubViewBuilder> ? routes, ControllerSetup? setup}) → Future<WebFController?> - Adds a new controller with prerendering enabled.
-
attachController(
String name, BuildContext context) → void - Attaches a named controller to a Flutter BuildContext.
-
detachController(
String name, BuildContext? context) → void - Detaches a named controller from a Flutter BuildContext.
-
disposeAll(
) → Future< void> - Disposes all controllers managed by this instance
-
getController(
String name) → Future< WebFController?> - Asynchronously retrieves or recreates a controller by name.
-
getControllerName(
WebFController controller) → String? - Finds the name associated with a specific controller instance
-
getControllerState(
String name) → ControllerState? - Gets the current state of a named controller
-
getControllerSync(
String name) → WebFController? - Synchronously retrieves a controller by name without recreation.
-
getRouterBuilderBySettings(
BuildContext context, String pageName, RouteSettings settings) → Widget? - Gets the appropriate widget for a specific route within a named controller.
-
hasController(
String name) → bool - Checks if a controller with the given name exists in the manager
-
initialize(
WebFControllerManagerConfig config) → void - Initializes the manager with custom configuration.
-
isControllerAlive(
String name) → bool - Checks if a controller with the given name exists and is managed.
-
isControllerAttached(
String name) → bool - Checks if a controller is currently attached to Flutter.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerController(
String name, WebFController controller) → WebFController - Manually registers an existing WebFController with the manager.
-
removeAndDisposeController(
String name) → Future< void> - Removes and fully disposes a controller by name
-
removeController(
String name) → WebFController? - Removes a controller from the manager without disposing it
-
startDevTools(
{int port = 9222, String address = '0.0.0.0'}) → Future< void> - Starts the Chrome DevTools service for debugging all managed controllers
-
stopDevTools(
) → Future< void> - Stops the Chrome DevTools service
-
toString(
) → String -
A string representation of this object.
inherited
-
updateWithPreload(
{required String name, ControllerFactory? createController, required WebFBundle bundle, Duration? timeout, Map< String, SubViewBuilder> ? routes, ControllerSetup? setup}) → Future<WebFController?> - Updates an existing controller with a new instance using preloading
-
updateWithPrerendering(
{required String name, ControllerFactory? createController, required WebFBundle bundle, Duration? timeout, Map< String, SubViewBuilder> ? routes, ControllerSetup? setup}) → Future<WebFController?> - Updates an existing controller with a new instance using prerendering
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → WebFControllerManager
-
Gets the singleton instance of the manager.
no setter
Static Methods
-
getInstance(
String name) → Future< WebFController?> - Static convenience method to get a controller by name.
-
getInstanceSync(
String name) → WebFController? - Static convenience method to get a controller synchronously.