factory<S> static method

Bind<S> factory<S>(
  1. InstanceBuilderCallback<S> builder, {
  2. bool autoRemove = true,
  3. bool assignId = true,
  4. String? tag,
})

Creates a binding with a custom factory function.

This is the most flexible binding method as it allows you to create a dependency with a custom factory function without registering it in the global GetX service locator.

Parameters:

  • builder: Function that creates the dependency
  • autoRemove: If true, the instance will be removed on widget disposal
  • assignId: If true, an ID will be assigned to the instance
  • tag: Optional tag for identifying this specific instance

Returns a binding widget that can be used in the widget tree.

Implementation

static Bind<S> factory<S>(
  InstanceBuilderCallback<S> builder, {
  bool autoRemove = true,
  bool assignId = true,
  String? tag,
}) =>
    _FactoryBind<S>(
      init: () => builder(),
      autoRemove: autoRemove,
      assignId: assignId,
      tag: tag,
    );