getObjectInScope method

T? getObjectInScope({
  1. required String type,
  2. required String scopeId,
  3. int index = 0,
})

Returns object in given scope with given index

Implementation

T? getObjectInScope({
  required String type,
  required String scopeId,
  int index = 0,
}) {
  final objects = _instances[scopeId]?[type] ?? [];

  if (objects.isEmpty) {
    return null;
  }

  if (index < 0 || index >= objects.length) {
    throw IllegalArgumentException(
      message:
          'The index = $index value must be non-negative and less than count of references of $type in $scopeId.',
    );
  }

  return objects[index];
}