lazyPut<S> method

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

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

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

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

If you need to make use of JuneState's life-cycle (onInit(), onStart(), onClose()) fenix is a great choice to mix with JuneBuilder() and JuneX() widgets, and/or JuneMaterialApp Navigation.

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

Subsequent calls to June.lazyPut() with the same parameters (<S> and optionally tag will not override the original).

Implementation

void lazyPut<S>(
  BuilderPattern<S> builder, {
  String? tag,
  bool? fenix,
  bool permanent = false,
}) {
  _insert(
    isSingleton: true,
    name: tag,
    permanent: permanent,
    builder: builder,
    fenix: fenix ??
        June.intelligentManagement == IntelligentManagement.keepFactory,
  );
}