PubClientConfig.fromYaml constructor

PubClientConfig.fromYaml(
  1. Object? yaml
)

Implementation

factory PubClientConfig.fromYaml(Object? yaml) {
  if (yaml == null) {
    return const PubClientConfig();
  }

  if (yaml is! Map<Object?, Object?>) {
    throw MelosConfigException('pub must be a map if provided.');
  }

  final timeoutSeconds = assertKeyIsA<int?>(
    key: 'timeoutSeconds',
    map: yaml,
  );
  final retryMap = assertKeyIsA<Map<Object?, Object?>?>(
    key: 'retry',
    map: yaml,
  );

  final retry = retryMap == null
      ? const RetryBackoff()
      : _retryFromYaml(retryMap);

  return PubClientConfig(
    requestTimeout: _timeoutFromSeconds(timeoutSeconds),
    retryBackoff: retry,
  );
}