dispatch method
约定: dispatch().then 代表 网络&业务逻辑 都是成功
Implementation
Future<BaseModel<T>> dispatch() {
return DioManager.fetch(getUrl(),
data: param, queryParameters: queryParameters, options: opt, cancelToken: cancelToken)
.then((response) {
result = transformModelFromResponseData(response.data);
result.response = response;
if (result.isSuccess) {
serializerJson();
return result;
} else {
if (showToast) {
onShowToast(msg: result.msg ?? '加载失败');
}
final dioException = DioException(
requestOptions: response.requestOptions,
response: response,
type: DioExceptionType.badResponse,
error: result.msg);
return Future.error(dioException);
}
});
}