lazyPut<S> method
- InstanceBuilderCallback<
S> builder, { - String? tag,
- bool? fenix,
- bool permanent = false,
Creates a new Instance lazily from the <S>builder() callback.
The first time you call Jet.find(), the builder() callback will create
the Instance and persisted as a Singleton (like you would
use Jet.put()).
Using Jet.smartManagement as SmartManagement.keepFactory has
the same outcome as using fenix:true :
The internal register of builder() will remain in memory to recreate
the Instance if the Instance has been removed with Jet.delete().
Therefore, future calls to Jet.find() will return the same Instance.
If you need to make use of JetxController's life-cycle
(onInit(), onStart(), onClose()) fenix is a great choice to mix with
JetBuilder() and JetX() widgets, and/or JetMaterialApp Navigation.
You could use Jet.lazyPut(fenix:true) in your app's main() instead
of Bindings() for each JetPage.
And the memory management will be similar.
Subsequent calls to Jet.lazyPut() with the same parameters
(<S> and optionally tag will not override the original).
Implementation
void lazyPut<S>(
InstanceBuilderCallback<S> builder, {
String? tag,
bool? fenix,
bool permanent = false,
}) {
_insert(
isSingleton: true,
name: tag,
permanent: permanent,
builder: builder,
fenix: fenix ?? Jet.smartManagement == SmartManagement.keepFactory,
);
}