getBlocInstance static method

Bloc getBlocInstance(
  1. String blocKey,
  2. Bloc instance()
)

Provide the bloc class cached with blocKey otherwise instantiates with instance.

Implementation

static Bloc getBlocInstance(String blocKey, Bloc Function() instance) {
  var bloc = BlocCache._cache.blocs[blocKey];

  if (bloc != null) {
    return bloc;
  }

  bloc = instance();
  BlocCache._cache.blocs[blocKey] = bloc;

  return bloc;
}