getConfig function

Config? getConfig(
  1. Uri url, {
  2. required Map<String, List<Config>> configs,
  3. int configIndex = 0,
})

Fetches config based on URL

Implementation

Config? getConfig(
  Uri url, {
  required Map<String, List<Config>> configs,
  int configIndex = 0,
}) {
  for (final i in configs.keys) {
    if (url.host.contains(i)) {
      Config? config = configs[i]!.firstWhereIndexedOrNull(
        (i, _) => i == configIndex,
      );
      if (config == null) {
        return configs[i]![0];
      }
      return config;
    }
  }
  return null;
}