flutter 通过Dio调用接口报错 “is not a subtype of type 'DioError'”

拦截器中原代码如下:

@overrideonResponse(Response response) async{RequestOptions option = response.request;try {///一般只需要处理200的情况,300、400、500保留错误信息if (response.statusCode == 200 || response.statusCode == 201) {int code = response.data["code"];if (code == 0) {return new ResultData(response.data, true, ExceptionHandle.success,headers: response.headers);} else {return new ResultData(response.statusMessage, false, ExceptionHandle.success,headers: response.headers);}}} catch (e) {print(e.toString() + option.path);return new ResultData(ExceptionHandle.handleException(e).msg, false, response.statusCode,headers: response.headers);}return new ResultData(response.statusMessage, false, response.statusCode,headers: response.headers);
}

参考:https://blog.csdn.net/qq_34205937/article/details/108358553

修改后报错

后根据大佬的思路修改为:

@overrideonResponse(Response response) async{Map<String,dynamic> responseData = jsonDecode(response.toString());try {///一般只需要处理200的情况,300、400、500保留错误信息if (response.statusCode == 200 || response.statusCode == 201) {String code = responseData["code"];if (code=="0000") {return new ResultData(responseData["data"], true, ExceptionHandle.success,headers: response.headers);} else {return new ResultData(response.statusMessage, false, ExceptionHandle.success,headers: response.headers);}}} catch (e) {return new ResultData(ExceptionHandle.handleException(e).msg, false, response.statusCode,headers: response.headers);}return new ResultData(response.statusMessage, false, response.statusCode,headers: response.headers);}

解决了我所遇到的问题

Flutter Dio 报错is not a subtype of type ‘DioError‘相关推荐

  1. 关于配置双数据源报错org.apache.ibatis.binding.BindingException: Type interface is not known to the MapperRegis

    报错org.apache.ibatis.binding.BindingException: Type interface is not known to the MapperRegistry.,在网上 ...

  2. auto cad安装报错command line option syntax error.type command

    网上下载的cad2012安装包,自己解压出来按照发现报错command line option syntax error.type command,大概意思就是安装包不能包含中文目录,最后的解决办法就 ...

  3. SpringCloud - 整合Nacos启动报错Consider defining a bean of type IClientConfig

    SpringCloud - 整合Nacos启动报错Consider defining a bean of type IClientConfig 前言 一. 尝试解决Bug的几种不合适方案 1.1 添加 ...

  4. 解决启动报错Consider defining a bean of type ‘xxx‘ in your configuration.

    解决启动报错Consider defining a bean of type 'xxx' in your configuration. 报错截图 解决方法:查看注解是否同时存在@AllArgsCons ...

  5. 报错: Cannot convert value of type ‘java.lang.String‘ to required type

    报错: Cannot convert value of type 'java.lang.String' to required type Caused by: java.lang.IllegalSta ...

  6. Flutter Dart 报错 '_InternalLinkedHashMapdynamic, dynamic' is not a subtype of t

    '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic> ...

  7. Flutter 编译报错 Error: The method DioHttpHeaders.add has fewer named arguments than those Context

    1.报错问题:最近更新Android Studio 4.0 连同Flutter 一起更新,导致原有项目运行报错: Error: The method 'DioHttpHeaders.add' has ...

  8. 【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )

    文章目录 一.报错信息 二.解决方案 一.报错信息 Flutter 应用运行时报如下错误 : Launching lib\main.dart on Pixel 2 in debug mode... R ...

  9. 【错误记录】Flutter 组件报错 ( No Directionality widget found. | RichText widgets require a Directionality )

    文章目录 一.报错信息 二.解决方案 一.报错信息 报错信息 : Performing hot reload... Syncing files to device Pixel 2... Reloade ...

  10. 【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )

    文章目录 一.报错信息 二.问题分析 三.解决方案 一.报错信息 参考 [Flutter]Flutter Gallery 官方示例简介 博客 ; Flutter Galley 开源项目运行时 , 部署 ...

最新文章

  1. c++ map 的基本操作
  2. mysql 白皮书_mysql企业版 《 MySQL企业版中文白皮书 》.cn.doc
  3. FFTW在VS中集成与测试详解
  4. 互联网日报 | 5月3日 星期一 | 京东物流通过港交所上市聆讯;理想汽车累计交付破5万辆;拼多多年活跃商户达860万
  5. Python编程练习题
  6. 《『若水新闻』客户端开发教程》——05.设计新闻列表UI
  7. webpack4.0学习笔记
  8. 蓝桥杯c语言基础试题答案,蓝桥杯试题C语言答案.doc
  9. 车林通购车之家--购车计算器模块--算法js
  10. 前端学习笔记-JS数据类型
  11. 三阶魔方还原步骤图_魔方小站三阶魔方盲拧视频教程 (蒙眼拧魔方教程|还原公式图解|3D动画)...
  12. 【10个精品网站】找素材、找图片、PDF在线工具、免费图片降噪修复、免费可商用字体、PPT模板
  13. [SFML]使用SFML复刻一个九宫幻卡小游戏(二)项目创建和SFML的配置
  14. 3.3 伴随矩阵法求逆矩阵
  15. aruco字典如DICT_4X4_50含义
  16. win10安装虚拟机Linux Centos7系统网络配置
  17. 类中的方法分类及propety,classmethod,staticmethod 装饰器
  18. 豪华曹操传2014 (数据以及存档文件修改)
  19. 我的世界java怎么写彩字_我的世界告示牌怎么打彩字 告示牌制作图文教程
  20. [每天读一点英文:那些给我勇气的句子]The Daffodil Principle

热门文章

  1. Python计算斗牛游戏的概率
  2. 常见的 Android 性能指标获取方式:CPU、FPS、Memory、GPU 、I/O、Network
  3. B2B供应链管理平台主流技术架构方案
  4. CwRsync安装配置
  5. 提交form表单时,修改action路径,增加参数
  6. 网页中用到的对比原则(一):色彩对比
  7. 计算机中的信息计量单位字,计算机中信息的计量单位.pdf
  8. 【Android】Doze模式识别与检测
  9. Excel 相对引用 绝对引用 区别是什么 如何快速转换 快捷键 F4
  10. 【数据分析方法论】关于思维、营销、咨询、绩效管理的一些经典分析框架