createEntity method

ModelEntity createEntity(
  1. String name, [
  2. int uid = 0
])

Implementation

ModelEntity createEntity(String name, [int uid = 0]) {
  final id = lastEntityId.id + 1;
  if (uid != 0 && containsUid(uid)) {
    throw StateError('uid already exists: $uid');
  }
  final uniqueUid = uid == 0 ? generateUid() : uid;

  var entity = ModelEntity.create(IdUid(id, uniqueUid), name, this);
  entities.add(entity);
  lastEntityId = entity.id;
  return entity;
}