Header.basicAuth constructor

Header.basicAuth({
  1. required String username,
  2. required String password,
  3. Encoding encoding = utf8,
})

Implementation

factory Header.basicAuth({
  required String username,
  required String password,
  Encoding encoding = utf8,
}) {
  final bytes = encoding.encode('$username:$password');
  final encoded = base64.encode(bytes);
  return Header(
    name: 'Authorization',
    value: 'Basic $encoded',
  );
}