request2PostBody method
dynamic
request2PostBody(})
Implementation
request2PostBody(String url, BuildContext context,
{bool isShowLoading = true,
String loadingContent = "请求中...",
dynamic data,
bool isShowToast = true, //是否弹出异常的message
Map<String, dynamic>? queryParameters,
Function? sendProcess}) async {
//async 所以回去了还是个future
if (isShowLoading) {
updateLoading(context, loadingContent);
}
dynamic response = await HttpUtils.postJson(url, data: data, sendProcessFunc: sendProcess);
// debugPrint("========拦截住===mixin==1=========$response");
// hideLoading(context, isShowLoading);
if (response is AppException) {
// debugPrint("========拦截住===mixin==2=========");
AppException err = response;
List<int> notShowCode = co?.notShowToastCode ?? [];
if (isShowToast && !notShowCode.contains(err.getCode())) {
ToastUtils.toast(err.getMessage());
}
if (!notShowCode.contains(err.getCode())) {
hideLoading(context, isShowLoading);
}
return Future.error(response);
} else {
hideLoading(context, isShowLoading);
}
return response;
}