factory<S> static method
Bind<S>
factory<S>(
- InstanceBuilderCallback<
S> builder, { - bool autoRemove = true,
- bool assignId = true,
- 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 dependencyautoRemove
: If true, the instance will be removed on widget disposalassignId
: If true, an ID will be assigned to the instancetag
: 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,
);