lazyPut<S> method

void lazyPut<S>(
  1. InstanceBuilderCallback<S> builder, {
  2. String? tag,
  3. bool fenix = false,
  4. bool permanent = false,
})

Creates a new Instance lazily from the <S>builder() callback.

The first time you call Sint.find(), the builder() callback will create the Instance and persisted as a Singleton (like you would use Sint.put()).

Using Sint.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 Sint.delete(). Therefore, future calls to Sint.find() will return the same Instance.

If you need to make use of SintController's life-cycle (onInit(), onStart(), onClose()) fenix is a great choice to mix with SintBuilder() and SINT() ui, and/or GetMaterialApp Navigation.

You could use Sint.lazyPut(fenix:true) in your app's main() instead of Bindings() for each GetPage. And the memory management will be similar.

Subsequent calls to Sint.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,
  bool permanent = false,
}) {
  _insert(
    isSingleton: true,
    name: tag,
    permanent: permanent,
    builder: builder,
    fenix: fenix,
  );
}