spawn<S> static method
Creates a binding and puts the specified dependency into the GetX service locator with a custom lifecycle.
This method is similar to put, but it creates a non-global instance that follows a custom lifecycle management approach.
Parameters:
builder: Function that creates the dependencytag: Optional tag for identifying this specific instancepermanent: If true, the instance won't be removed on widget disposal
Returns a binding widget that can be used in the widget tree.
Implementation
static Bind<S> spawn<S>(
InstanceBuilderCallback<S> builder, {
String? tag,
bool permanent = true,
}) {
// Register the dependency with GetX using spawn
Get.spawn<S>(builder, tag: tag, permanent: permanent);
// Return a factory binding with appropriate settings
return _FactoryBind<S>(
tag: tag,
global: false, // Spawn creates non-global instances
autoRemove: !permanent, // Invert permanent to get autoRemove behavior
);
}