addBasicAuthenticationHeader function

Map<String, String> addBasicAuthenticationHeader(
  1. Map<String, String> headers,
  2. String username,
  3. String password
)

In basic HTTP authentication, a request contains a header field in the form of Authorization: Basic

Implementation

Map<String, String> addBasicAuthenticationHeader(
    Map<String, String> headers, String username, String password) {
  headers['authorization'] =
      'Basic ' + base64.encode(utf8.encode('$username:$password'));
  return headers;
}