项目场景:

Flutter中接口response json数据解析为Model

问题描述:

发现某些字段,例如price价格,无论将字段数据类型定为double还是int,都有可能报错,解析失败。

  int? firstCount;int? orderAmount;int? amountPaid;int? orderCount;int? receiverCount;double? price;

原因分析:

price字段后台可能返回 int或double,所以数据类型无论选哪一个都不合适。

解决方案:

将这些数值型字段的数据类型定义为num就可以了。

  num? firstCount;num? orderAmount;num? amountPaid;num? orderCount;num? receiverCount;num? price;

Flutter报错: type ‘double‘ is not a subtype of type ‘int?‘或type ‘int‘ is not a subtype of type ‘double相关推荐

  1. Flutter报错BlocProvider.of() called with a context that does not contain a Bloc of type **.

    Flutter报错BlocProvider.of() called with a context that does not contain a Bloc of type **. 在使用flutter ...

  2. flutter报错Could not connect to lockdownd, error code -

    关于 flutter 报错信息解决方案 第一步: cmd+shift+g 前往 /var/db 文件夹,找到lockdown文件夹,修改读写权限 第二步 : 打开命令行,依次执行 brew updat ...

  3. flutter 报错java.net.URISyntaxException: Illegal character in opaque part at index 2

    记录flutter报错如下错误以及解决办法 FAILURE: Build failed with an exception. * What went wrong: Execution failed f ...

  4. 【错误记录】Flutter 报错 ( Could not resolve io.flutter:flutter_embedding_debug:1.0.0. )

    文章目录 一. 报错信息 二. 解决方案 三. 备选方案 一. 报错信息 从网上下载了一个 Flutter 工程代码 , 打开时 , 报如下错误 ; Launching lib\main.dart o ...

  5. 【错误记录】Flutter 报错 ( Android Studio 中 main.dart 左侧不显示设备栏 )

    文章目录 一.报错信息 二.解决方案 一 ( 备选方案 ) 三.解决方案 二 ( 推荐方案 ) 一.报错信息 为了解决 [错误记录]Flutter 构建报错 ( Because xxx require ...

  6. 【错误记录】Flutter 报错 ( Dart SDK is not configured )

    文章目录 一. 报错信息 二. 问题分析 三. 解决方案 一. 报错信息 从 GitHub 中下载源码后 , 在界面中报错 Dart SDK is not configured 如下图 : 二. 问题 ...

  7. 【错误记录】Flutter 报错 Downloading the Dart SDK using the BITS service failed, retrying with WebRequest...

    文章目录 一. 报错信息 二.解决方案 ( 检查镜像地址环境变量设置 ) 1.检查镜像地址环境变量设置 ( 错误方案 没有解决问题 ) 2.尝试使用官方地址 三.总结 1.官方镜像 ( 推荐方案 ) ...

  8. Flutter 报错:Could not resolve io.flutter:flutter_embedding_debug:1.0.0-ee76268252c22f5c11e82a7b87423c

    报错信息: 解决方法: 打开build.gradle文件buildscript {ext.kotlin_version = '1.3.50'repositories {google()jcenter( ...

  9. flutter报错: your app to be migrated to the Android embedding v2

    flutter 升级到3.0.0后,运行报错your app to be migrated to the Android embedding v2, 查看项目后发现Android embedding ...

  10. Flutter 报错:Unable to load asset: xxx.png 解决

    报错如下:* 1.新建的images文件夹要与pubspec.yaml同级 2.好像出现这条线才行,距离左边两个空 如上图所示,因为assets:是属于flutter下的项,所以assets:前面所留 ...

最新文章

  1. YOLOS:重新思考Transformer的泛化性能
  2. Science:AI领域那么多引人注目的「进展」,竟是无用功
  3. 新一代的树莓派3版本——Raspberry Pi 3 发布了
  4. Vue.js not detected
  5. python蚁群算法 路径规划_蚁群算法(1) - Python实现
  6. 关于CSDN官方对博文点赞漏洞的处理(Cookie劫持攻击)
  7. 项目复盘:从0到1,如何做好竞品分析?
  8. office选项-》高级-》显示 中, 显示此数目的“最近使用的文档” 为灰色,无法更改
  9. Swift中类的使用
  10. scala 抽象方法_Scala抽象类型
  11. 兴奋:支持安卓(android)、苹果手机和平板电脑的WayOs版本
  12. iNOC产品部--完全数计算
  13. python编程的区别_Python与其它编程语言的区别
  14. Linux 中文文件名乱码解决 FTP文件名乱码
  15. python基础——闭包函数和生成器
  16. USBKey使用openssl链接
  17. 计算机访问网络延迟越低越好吗,网速和网络延迟(网络延迟取决于什么)
  18. Android手势密码
  19. Zookeeper+Hadoop+Hbase完全分布搭建数据仓库安装部署说明
  20. bind dlz mysql ptr_Bind+DLZ+MySQL智能DNS的正向解析和反向解析实现方法

热门文章

  1. iptables 实现主机防火墙(四表五链)
  2. 家有千金之冰糖绿豆汤
  3. 重装系统后开机启动项菜单如何删除
  4. 【哼歌检索】十大语音搜索应用服务
  5. 【easyui】之DataGrid数据显示
  6. Windows系统(tips)
  7. [CSS]好看的渐变色网站
  8. raid5两块硬盘掉线数据恢复-服务器磁盘阵列数据恢复方法
  9. 英语单词词性顺口溜_英语单词词性分类
  10. 计算机感染病毒后 一定不能清除的措施是,货物周转量比上年同期下降最多的是()。...