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,
- ResponseType? responseType,
- String? tag,
- bool? retryable,
- Map<
String, dynamic> ? extra, - 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 — unless you
pass retryable: true for a call you know only reads. See get for
retryable and extra.
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,
ResponseType? responseType,
String? tag,
bool? retryable,
Map<String, dynamic>? extra,
bool showLoader = true,
}) {
return _respond(
HttpMethod.post,
endpoint,
data: data,
params: params,
headers: headers,
tag: tag,
retryable: retryable,
extra: extra,
cancelToken: cancelToken,
);
}