setBasicAuthorization method Null safety

void setBasicAuthorization(
  1. String username,
  2. String password
)

Adds basic authorization to requests from this agent.

Base-64 encodes username and password with a colon separator, and sets it for the key 'authorization' in headers.

Implementation

void setBasicAuthorization(String username, String password) {
  headers["authorization"] =
      "Basic ${base64.encode("$username:$password".codeUnits)}";
}