DUIFactory class

Central factory class for creating Digia UI widgets, pages, and components.

DUIFactory is a singleton that serves as the main entry point for creating UI elements from JSON configurations. It manages UI resources, widget registries, and provides methods for creating various UI elements with optional customization.

Key responsibilities:

  • Creating pages and components from JSON definitions
  • Managing UI resources (icons, images, fonts, colors)
  • Handling widget registration for custom components
  • Providing resource override capabilities
  • Managing navigation routes and bottom sheets

Example usage:

// Create a page
Widget page = DUIFactory().createPage('pageId', {'key': 'value'});

// Create a component
Widget component = DUIFactory().createComponent('componentId', args);

// Register custom widget
DUIFactory().registerWidget<MyProps>(
  'custom/myWidget',
  MyProps.fromJson,
  (props, childGroups) => MyCustomWidget(props),
);

Constructors

DUIFactory()
Returns the singleton instance of DUIFactory
factory

Properties

actionExecutionContext ↔ ActionExecutionContext
Execution context for the factory
getter/setter pair
bindingRegistry ↔ MethodBindingRegistry
Registry for method bindings used in expressions
getter/setter pair
configProvider ↔ ConfigProvider
Page and component configuration provider
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
resources UIResources
UI resources including icons, images, fonts, and colors
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
widgetRegistry ↔ VirtualWidgetRegistry
Registry for managing virtual widget types and their builders
getter/setter pair

Methods

clearEnvironmentVariable(String varName) → void
Clears a single environment variable value at runtime.
clearEnvironmentVariables(List<String> varNames) → void
Clears multiple environment variables at once.
createComponent(String componentid, JsonLike? args, {Map<String, IconData>? overrideIcons, Map<String, ImageProvider<Object>>? overrideImages, Map<String, TextStyle>? overrideTextStyles, Map<String, Color?>? overrideColorTokens, GlobalKey<NavigatorState>? navigatorKey, ObservabilityContext? observabilityContext}) Widget
Creates a reusable component widget from a JSON configuration.
createInitialPage({Map<String, IconData>? overrideIcons, Map<String, ImageProvider<Object>>? overrideImages, Map<String, TextStyle>? overrideTextStyles, Map<String, Color?>? overrideColorTokens}) Widget
Creates the initial page of the application based on configuration.
createPage(String pageId, JsonLike? pageArgs, {Map<String, IconData>? overrideIcons, Map<String, ImageProvider<Object>>? overrideImages, Map<String, TextStyle>? overrideTextStyles, Map<String, Color?>? overrideColorTokens, GlobalKey<NavigatorState>? navigatorKey, DUIPageController? pageController}) Widget
Creates a page widget from a JSON configuration with optional resource overrides.
createPageRoute(String pageId, JsonLike? pageArgs, {Map<String, IconData>? overrideIcons, Map<String, ImageProvider<Object>>? overrideImages, Map<String, TextStyle>? overrideTextStyles, Map<String, Color?>? overrideColorTokens, GlobalKey<NavigatorState>? navigatorKey, DUIPageController? pageController}) Route<Object>
Creates a Flutter Route for navigation to a specific page.
destroy() → void
Destroys the factory and cleans up all resources.
initialize({ConfigProvider? pageConfigProvider, Map<String, IconData>? icons, Map<String, ImageProvider<Object>>? images, DUIFontFactory? fontFactory}) → void
Initializes the singleton factory with all necessary configuration and resources.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerJsonWidget(String type, VirtualWidget builder(JsonLike props, Map<String, List<VirtualWidget>>? childGroups)) → void
Registers a new custom widget type that works directly with JSON properties.
registerWidget<T>(String type, T fromJsonT(JsonLike), VirtualWidget builder(T props, Map<String, List<VirtualWidget>>? childGroups)) → void
Registers a new custom widget type with type-safe properties.
setEnvironmentVariable(String varName, Object? value) → void
Sets a single environment variable value at runtime.
setEnvironmentVariables(Map<String, Object?> variables) → void
Sets multiple environment variables at once.
showBottomSheet<T>(BuildContext context, String viewId, JsonLike? args, {double scrollControlDisabledMaxHeightRatio = 1, Color? backgroundColor, Color? barrierColor, BoxBorder? border, BorderRadius? borderRadius, WidgetBuilder? iconBuilder, bool useSafeArea = true, GlobalKey<NavigatorState>? navigatorKey}) Future<T?>
Shows a bottom sheet with a Digia UI view (page or component).
showUIAction(UIActionType actionType, BuildContext context, String componentId, {Map<String, Object?>? componentArgs}) → void
Performs a UI action via the global DigiaUIManager managers.
toString() String
A string representation of this object.
inherited

Operators

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