mergedWith method

  1. @override
CallOptions mergedWith(
  1. CallOptions? other
)
override

Implementation

@override
CallOptions mergedWith(CallOptions? other) {
  if (other == null) return this;

  final mergedMetadata = Map.from(metadata)..addAll(other.metadata);
  final mergedTimeout = other.timeout ?? timeout;
  final mergedProviders = List.from(metadataProviders)
    ..addAll(other.metadataProviders);

  if (other is! WebCallOptions) {
    return WebCallOptions._(Map.unmodifiable(mergedMetadata), mergedTimeout,
        List.unmodifiable(mergedProviders),
        bypassCorsPreflight: bypassCorsPreflight,
        withCredentials: withCredentials);
  }

  final mergedBypassCorsPreflight =
      other.bypassCorsPreflight ?? bypassCorsPreflight;
  final mergedWithCredentials = other.withCredentials ?? withCredentials;
  return WebCallOptions._(Map.unmodifiable(mergedMetadata), mergedTimeout,
      List.unmodifiable(mergedProviders),
      bypassCorsPreflight: mergedBypassCorsPreflight,
      withCredentials: mergedWithCredentials);
}