findAuthenticationInMap function Null safety

Authentication? findAuthenticationInMap(
  1. Map map
)

Checks the passed in map for keys in COMMON_GITHUB_TOKEN_ENV_KEYS. The first one that exists is used as the github token to call Authentication.withToken with. If the above fails, the GITHUB_USERNAME and GITHUB_PASSWORD keys will be checked. If those keys both exist, then Authentication.basic will be used.

Implementation

Authentication? findAuthenticationInMap(Map map) {
  for (final key in COMMON_GITHUB_TOKEN_ENV_KEYS) {
    if (map.containsKey(key)) {
      return Authentication.withToken(map[key]);
    }
    if (map['GITHUB_USERNAME'] is String && map['GITHUB_PASSWORD'] is String) {
      return Authentication.basic(
          map['GITHUB_USERNAME'], map['GITHUB_PASSWORD']);
    }
  }
  return null;
}