add<T extends Model> static method

void add<T extends Model>(
  1. ModelBuilder<T> modelBuilder, {
  2. String? id,
  3. bool lazy = true,
})

Adds a model to the Store. No model is added if a model of same type already exists. Model is added lazily unless lazy is false that is no model is created until it is accessed for the first time. To add a model when another one of same type already exists, provide a unique string id using the optional id parameter.

Implementation

static void add<T extends Model>(ModelBuilder<T> modelBuilder,
    {String? id, bool lazy = true}) {
  final key = id ?? T;
  if (lazy) {
    _LazyModelStore.add(modelBuilder, key);
  } else {
    _EagerModelStore.add(modelBuilder(), key);
  }
}