decreaseReferences method

void decreaseReferences(
  1. String scopeId,
  2. Type type, {
  3. int index = 0,
})

Substracts 1 to references for given type

Implementation

void decreaseReferences(String scopeId, Type type, {int index = 0}) {
  if (_references.containsKey(scopeId)) {
    final typesCounts = _references[scopeId]!;

    if (typesCounts.containsKey(type) && typesCounts[type] != null) {
      final objects = typesCounts[type]!;

      if (objects.isEmpty) {
        return;
      }

      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.',
        );
      }

      objects[index] = objects[index] - 1;
    }
  }
}