postRequest function
Future
postRequest(
- BuildContext context,
- String url,
- dynamic data, {
- bool showProgressIndicator = true,
- Map? headers,
Implementation
Future postRequest(BuildContext context, String url, dynamic data,
{bool showProgressIndicator = true, Map? headers}) {
Map customHeaders = headers != null ? headers : {};
return dio
.post(url,
data: data,
options: Options(headers: {
...customHeaders as Map<String, dynamic>
}))
.catchError((err) {
showSnackBar(context, "Sorry an error occurred");
}).catchError((err) {
if (showProgressIndicator) showSnackBar(context, "Sorry an error occurred");
print(err);
});
}