lazyPut<S> method
Creates a new Instance lazily from the <S>builder()
callback.
The first time you call Get.find()
, the builder()
callback will create
the Instance and persisted as a Singleton (like you would use
Get.put()
).
Using Get.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 Get.delete()
.
Therefore, future calls to Get.find()
will return the same Instance.
If you need to make use of GetxController's life-cycle
(onInit(), onStart(), onClose()
)
fenix
is a great choice to mix with GetBuilder
and GetX
widgets,
and/or GetMaterialApp Navigation.
You could use Get.lazyPut(fenix:true)
in your app's main()
instead of
Bindings
for each GetPage.
And the memory management will be similar.
Subsequent calls to Get.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 = false}) {
GetInstance().lazyPut<S>(builder, tag: tag, fenix: fenix);
}