post method
Future<Either<Failure, Response> >
post({
- required String endpoint,
- Object? data,
- Map<
String, dynamic> ? params, - Duration? receiveTimeout,
- Duration? sendTimeout,
- Map<
String, String> ? headers, - ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
- CancelToken? cancelToken,
- bool showLoader = true,
override
Sends a POST request to endpoint.
Use for creating resources or submitting forms. Pass the request body
as data (a Map, a model's .toJson(), or FormData for file uploads
— though upload is easier for that).
Example:
final result = await _api.post(
endpoint: '/auth/login',
data: {'email': email, 'password': password},
);
Never auto-retried on a timeout: the server may already have processed it, and repeating it could create the same record twice.
Implementation
@override
Future<Either<Failure, Response>> post({
required String endpoint,
Object? data,
Map<String, dynamic>? params,
Duration? receiveTimeout,
Duration? sendTimeout,
Map<String, String>? headers,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
CancelToken? cancelToken,
bool showLoader = true,
}) {
return _respond(HttpMethod.post, endpoint,
data: data, params: params, headers: headers);
}