create<T extends Object?> method

T? create<T extends Object?>({
  1. required ContextBuilder<T> builder,
  2. String? id,
  3. Object? ref,
})

Registers, creates and gets the instance of T with or without id given.

Returns it, else return null.

Implementation

T? create<T extends Object?>({
  required ContextBuilder<T> builder,
  String? id,
  Object? ref,
}) {
  register<T>(builder: builder, id: id);

  final reactterInstance = _getAndCreateIfNotExtist<T>(id);

  if (ref != null) {
    reactterInstance?.refs.add(ref.hashCode);
  }

  return reactterInstance?.instance;
}