wrapAsBasicAuthHeaderValue function

String wrapAsBasicAuthHeaderValue(
  1. String key
)

Returns a value that is compliant with the HTTP auth header format by encoding and wrapping the provided auth key as a Basic auth value.

Implementation

String wrapAsBasicAuthHeaderValue(String key) {
  // Encode the key as Base64 and prepend the default scheme name.
  var encodedKey = base64.encode(utf8.encode(key));
  return '$basicAuthSchemeName $encodedKey';
}