lazyPut<S> static method
Bind<S>
lazyPut<S>(
- InstanceBuilderCallback<
S> builder, { - String? tag,
- bool fenix = false,
- VoidCallback? onClose,
Creates a lazy binding and registers a builder function in the GetX service locator.
The dependency will only be created when it's requested for the first time. Use this to defer instantiation until the dependency is actually needed.
Parameters:
builder
: Function that creates the dependency when neededtag
: Optional tag for identifying this specific instancefenix
: If true, the instance will be recreated after it's been deletedonClose
: Optional callback to run when the instance is removed
Returns a binding widget that can be used in the widget tree.
Implementation
static Bind<S> lazyPut<S>(
InstanceBuilderCallback<S> builder, {
String? tag,
bool fenix = false,
VoidCallback? onClose,
}) {
// Register the lazy builder with GetX
Get.lazyPut<S>(builder, tag: tag, fenix: fenix);
// Return a factory binding with appropriate settings
return _FactoryBind<S>(
tag: tag,
dispose: switch (onClose) {
null => null,
var callback => (_) => callback()
},
);
}