clone method

Scope clone()

Clones the current Scope

Implementation

Scope clone() {
  final clone = Scope(_options)
    ..level = level
    ..fingerprint = List.from(fingerprint)
    .._transaction = _transaction
    ..span = span
    .._enableScopeSync = false;

  clone._setUserSync(user);

  final tags = List.from(_tags.keys);
  for (final tag in tags) {
    final value = _tags[tag];
    if (value != null) {
      clone._setTagSync(tag, value);
    }
  }

  for (final extraKey in List.from(_extra.keys)) {
    clone._setExtraSync(extraKey, _extra[extraKey]);
  }

  for (final breadcrumb in List.from(_breadcrumbs)) {
    clone._addBreadCrumbSync(breadcrumb);
  }

  for (final eventProcessor in List.from(_eventProcessors)) {
    clone.addEventProcessor(eventProcessor);
  }

  for (final entry in Map.from(contexts).entries) {
    if (entry.value != null) {
      clone._setContextsSync(entry.key, entry.value);
    }
  }

  for (final attachment in List.from(_attachments)) {
    clone.addAttachment(attachment);
  }

  return clone;
}