AuthHeader class
This class represents the authorization header.
The name of the header will be set to name, and the token that will be the value of the header will be set to value.
It can be used in conjunction with the http package as follows.
Example:
import 'package:authorization_header/authorization_header.dart';
import 'package:http/http.dart' as http;
void main() async {
/// You can switch between Default and Proxy in the constructor.
final authHeader = Auth.of().bearer(token: 'test_token');
final proxyAuthHeader = Auth.ofProxy().bearer(token: 'test_token');
print(authHeader); // -> name: Authorization, value: Bearer test
print(proxyAuthHeader); // -> name: Proxy-Authorization, value: Bearer test
await http.post(
Uri.parse('https://test.com'),
headers: {
authHeader.name: authHeader.value,
proxyAuthHeader.name: proxyAuthHeader.value,
},
);
}
Constructors
- AuthHeader.from({required String name, required String value})
- Returns the new instance of AuthHeader based on arguments.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override