mergedWith method

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

Implementation

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

  final mergedMetadata = Map.of(metadata)..addAll(other.metadata);
  final mergedTimeout = other.timeout ?? timeout;
  final mergedProviders = List.of(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,
  );
}