resolve method

String? resolve(
  1. List<DebugEnvironment> group,
  2. String baseUrl
)

The base URL to use for a request of a Dio with the environments group.

Only rewrites baseUrl when it is one of the group's URLs, so requests to other hosts are left alone. Returns null for no change.

Implementation

String? resolve(List<DebugEnvironment> group, String baseUrl) {
  final name = selected;
  if (name == null) return null;
  final target = group.where((e) => e.name == name).firstOrNull;
  if (target == null) return null;
  final current = _normalize(baseUrl);
  if (!group.any((e) => _normalize(e.baseUrl) == current)) return null;
  return current == _normalize(target.baseUrl) ? null : target.baseUrl;
}