UIStateWorkflow constructor

UIStateWorkflow({
  1. required UIStateManager managerFactory(
    1. ProviderContext context
    ),
  2. required UIStatePage pageSelector(
    1. PageConfiguration? config
    ),
  3. required Widget builder(
    1. BuildContext context,
    2. WorkflowContext wfContext
    ),
  4. Set<Listenable> valueProviders = const {},
  5. bool changeHandler(
    1. ProviderContext context
    )?,
  6. bool enableLocations = false,
  7. bool useFullLocations = false,
  8. LocationConverter? locationConverter,
})

Creates an instance of UIStateWorkflow.

The manager which is used by the workflow is created by managerFactory. The context available to this factory method contains the value providers which are provided through valueProviders. Triggers and conditions on states and trantitions should only depend on providers known to the workflow, as they are listened on. This way workflow conditions can be evaluated on every change, and trigger transitions can be applied if needed. Whether a change notification should trigger a reevaluation of the worklow conditions, can be adjusted by defining changeHandler.

Location adjustment

By default, the engine does not display a URL for the current state. This behavior can be configured by enableLocations and enableFullLocations. The exact URL to state association can be further adjusted by passing in an custom implementation of LocationConverter for locationConverter. By omitting the parameter, the default implementation is used. See LocationConverter for further information about this.

Page generation

The association between pages and workflow states is created with the pageSelector function. Each existing state, with exception of group states, should be associated with an [UIStatePage, as they can not be targeted directly.

Implementation

UIStateWorkflow({
  required UIStateManager Function(ProviderContext context) managerFactory,
  required UIStatePage Function(PageConfiguration? config) pageSelector,
  required Widget Function(BuildContext context, WorkflowContext wfContext)
      builder,
  Set<Listenable> valueProviders = const {},
  bool Function(ProviderContext context)? changeHandler,
  bool enableLocations = false,
  bool useFullLocations = false,
  LocationConverter? locationConverter,
})  : _context = _createContext(
        managerFactory,
        valueProviders,
        enableLocations,
        useFullLocations,
        pageSelector,
        locationConverter,
      ),
      _builder = builder,
      _changeHandler = changeHandler {
  _init();
}