post abstract method
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).
Example:
final result = await _api.post(
endpoint: '/auth/login',
data: {'email': email, 'password': password},
);
File upload example:
final result = await _api.post(
endpoint: '/upload',
data: FormData.fromMap({
'file': await MultipartFile.fromFile(filePath),
}),
onSendProgress: (sent, total) => print('${sent / total * 100}%'),
);
Implementation
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,
});