dispatch method
约定: dispatch().then 代表 网络&业务逻辑 都是成功
Implementation
Future<BaseModel<T>> dispatch() {
assert(path.isNotEmpty);
return DioManager()
.dio
.request(path, data: param, queryParameters: queryParameters, options: opt)
.then((response) {
result = transformModelFromResponseData(response.data);
result.response = response;
if (result.isSuccess) {
serializerJson();
return result;
} else {
if (canShowToast) {
showToast(msg: result.msg ?? '加载失败');
}
onResponseError(result);
return Future.error(result);
}
}, onError: (e) {
networkError(e);
throw e;
});
}