krequestBool function
请求数据,返回bool数据,接口调用成功就返回结果
var data = await krequestBool(() => ApiRepository.get.getTemporaryCode());
Implementation
Future<bool> krequestBool(Future<Response> Function() request,
{bool isThrowEx = true}) async {
try {
var json = await k_request(request);
var result = ResultBoolDto.fromJson(json);
if (result.isSuccess()) {
return true;
} else {
if (isThrowEx) {
throw NetException(code: result.errorCode, message: result.message);
} else {
return false;
}
}
} on Exception catch (ex) {
KHttpPlatform.get.throwHandler?.handleError(ex);
}
return false;
}