post method Null safety
- String url,
- {Duration? timeout,
- Map<
String, String> params = const {}, - Map<
String, String> headers = const {}, - ResponseType responseType = ResponseType.json,
- DownloadCallback? onDownloadProgress,
- ValidateCallback? validateStatus,
- dynamic data}
Aliase to GET
method.
Implementation
Future<Response> post(
String url, {
/// Time that the server will wait for the response to the request.
/// The connection will be interrupted if you hear timeout.
Duration? timeout,
/// Adds query params.
/// Must be a plain object or a URLSearchParams object.;
/// exe:
///```dart
/// uno.get('/users',params: {
/// 'id': '1',
/// });
/// ```
/// This generate ['/users?id=1'];
Map<String, String> params = const {},
/// Headers of request.
Map<String, String> headers = const {},
/// Represents the [Response] data type.
/// Could use:
/// ```dart
/// ResponseType.json //default
/// ResponseType.plain
/// ResponseType.arraybuffer
/// ResponseType.stream
/// ```
ResponseType responseType = ResponseType.json,
/// Callback from API to client about request`s upload.
/// ```dart
/// uno(
/// method: 'get',
/// url: 'http://bit.ly/2mTM3nY',
/// // you can use plain, json(default), arraybuffer and stream;
/// responseType: ResponseType.arraybuffer,
/// onDownloadProgress: (total, current) {
/// final percentCompleted = (current / total * 100).round();
/// print('completed: $percentCompleted%');
/// },
/// ).then((response) async {
/// await File('ada_lovelace.jpg').writeAsBytes(response.data);
/// });
/// ```
DownloadCallback? onDownloadProgress,
/// Using the validateStatus config option, you can define HTTP code(s) that should throw an error.
/// ```dart
/// axios.get('/user/12345', {
/// validateStatus: (status) {
/// return status < 500; // Resolve only if the status code is less than 500
/// }
/// });
/// ```
ValidateCallback? validateStatus,
/// `data` is the data to be sent as the request body
/// Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
/// - String, Map(json) or FormData
dynamic data,
});