Flutter Dio 报错is not a subtype of type ‘DioError‘
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‘相关推荐
- 关于配置双数据源报错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.,在网上 ...
- auto cad安装报错command line option syntax error.type command
网上下载的cad2012安装包,自己解压出来按照发现报错command line option syntax error.type command,大概意思就是安装包不能包含中文目录,最后的解决办法就 ...
- SpringCloud - 整合Nacos启动报错Consider defining a bean of type IClientConfig
SpringCloud - 整合Nacos启动报错Consider defining a bean of type IClientConfig 前言 一. 尝试解决Bug的几种不合适方案 1.1 添加 ...
- 解决启动报错Consider defining a bean of type ‘xxx‘ in your configuration.
解决启动报错Consider defining a bean of type 'xxx' in your configuration. 报错截图 解决方法:查看注解是否同时存在@AllArgsCons ...
- 报错: 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 ...
- Flutter Dart 报错 '_InternalLinkedHashMapdynamic, dynamic' is not a subtype of t
'_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic> ...
- 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 ...
- 【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )
文章目录 一.报错信息 二.解决方案 一.报错信息 Flutter 应用运行时报如下错误 : Launching lib\main.dart on Pixel 2 in debug mode... R ...
- 【错误记录】Flutter 组件报错 ( No Directionality widget found. | RichText widgets require a Directionality )
文章目录 一.报错信息 二.解决方案 一.报错信息 报错信息 : Performing hot reload... Syncing files to device Pixel 2... Reloade ...
- 【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )
文章目录 一.报错信息 二.问题分析 三.解决方案 一.报错信息 参考 [Flutter]Flutter Gallery 官方示例简介 博客 ; Flutter Galley 开源项目运行时 , 部署 ...
最新文章
- c++ map 的基本操作
- mysql 白皮书_mysql企业版 《 MySQL企业版中文白皮书 》.cn.doc
- FFTW在VS中集成与测试详解
- 互联网日报 | 5月3日 星期一 | 京东物流通过港交所上市聆讯;理想汽车累计交付破5万辆;拼多多年活跃商户达860万
- Python编程练习题
- 《『若水新闻』客户端开发教程》——05.设计新闻列表UI
- webpack4.0学习笔记
- 蓝桥杯c语言基础试题答案,蓝桥杯试题C语言答案.doc
- 车林通购车之家--购车计算器模块--算法js
- 前端学习笔记-JS数据类型
- 三阶魔方还原步骤图_魔方小站三阶魔方盲拧视频教程 (蒙眼拧魔方教程|还原公式图解|3D动画)...
- 【10个精品网站】找素材、找图片、PDF在线工具、免费图片降噪修复、免费可商用字体、PPT模板
- [SFML]使用SFML复刻一个九宫幻卡小游戏(二)项目创建和SFML的配置
- 3.3 伴随矩阵法求逆矩阵
- aruco字典如DICT_4X4_50含义
- win10安装虚拟机Linux Centos7系统网络配置
- 类中的方法分类及propety,classmethod,staticmethod 装饰器
- 豪华曹操传2014 (数据以及存档文件修改)
- 我的世界java怎么写彩字_我的世界告示牌怎么打彩字 告示牌制作图文教程
- [每天读一点英文:那些给我勇气的句子]The Daffodil Principle