extractModel<R> method
等待响应完成后,自动提取模型 支持链式调用,无需中间变量
示例:
final uploadResult = await http.send(...).extractModel<FileUploadResult>(
FileUploadResult.fromConfigJson,
);
Implementation
Future<R?> extractModel<R>(
R? Function(Map<String, dynamic> json) fromJson,
) async {
final response = await this;
final result = response.extractModel<R>(fromJson);
// 注意:不再在这里关闭 loading
// - 如果使用了 http.isLoading.send(),这是链式调用,loading 应该由链式调用的最后一步关闭
// - 如果使用了 http.send(isLoading: true),finally 块会处理关闭 loading
// - 如果后续有 thenWith,loading 应该由 thenWith 链路的最后一步关闭
return result;
}