Flutter报错: type ‘double‘ is not a subtype of type ‘int?‘或type ‘int‘ is not a subtype of type ‘double
项目场景:
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相关推荐
- 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 ...
- flutter报错Could not connect to lockdownd, error code -
关于 flutter 报错信息解决方案 第一步: cmd+shift+g 前往 /var/db 文件夹,找到lockdown文件夹,修改读写权限 第二步 : 打开命令行,依次执行 brew updat ...
- 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 ...
- 【错误记录】Flutter 报错 ( Could not resolve io.flutter:flutter_embedding_debug:1.0.0. )
文章目录 一. 报错信息 二. 解决方案 三. 备选方案 一. 报错信息 从网上下载了一个 Flutter 工程代码 , 打开时 , 报如下错误 ; Launching lib\main.dart o ...
- 【错误记录】Flutter 报错 ( Android Studio 中 main.dart 左侧不显示设备栏 )
文章目录 一.报错信息 二.解决方案 一 ( 备选方案 ) 三.解决方案 二 ( 推荐方案 ) 一.报错信息 为了解决 [错误记录]Flutter 构建报错 ( Because xxx require ...
- 【错误记录】Flutter 报错 ( Dart SDK is not configured )
文章目录 一. 报错信息 二. 问题分析 三. 解决方案 一. 报错信息 从 GitHub 中下载源码后 , 在界面中报错 Dart SDK is not configured 如下图 : 二. 问题 ...
- 【错误记录】Flutter 报错 Downloading the Dart SDK using the BITS service failed, retrying with WebRequest...
文章目录 一. 报错信息 二.解决方案 ( 检查镜像地址环境变量设置 ) 1.检查镜像地址环境变量设置 ( 错误方案 没有解决问题 ) 2.尝试使用官方地址 三.总结 1.官方镜像 ( 推荐方案 ) ...
- 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( ...
- 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 ...
- Flutter 报错:Unable to load asset: xxx.png 解决
报错如下:* 1.新建的images文件夹要与pubspec.yaml同级 2.好像出现这条线才行,距离左边两个空 如上图所示,因为assets:是属于flutter下的项,所以assets:前面所留 ...
最新文章
- YOLOS:重新思考Transformer的泛化性能
- Science:AI领域那么多引人注目的「进展」,竟是无用功
- 新一代的树莓派3版本——Raspberry Pi 3 发布了
- Vue.js not detected
- python蚁群算法 路径规划_蚁群算法(1) - Python实现
- 关于CSDN官方对博文点赞漏洞的处理(Cookie劫持攻击)
- 项目复盘:从0到1,如何做好竞品分析?
- office选项-》高级-》显示 中, 显示此数目的“最近使用的文档” 为灰色,无法更改
- Swift中类的使用
- scala 抽象方法_Scala抽象类型
- 兴奋:支持安卓(android)、苹果手机和平板电脑的WayOs版本
- iNOC产品部--完全数计算
- python编程的区别_Python与其它编程语言的区别
- Linux 中文文件名乱码解决 FTP文件名乱码
- python基础——闭包函数和生成器
- USBKey使用openssl链接
- 计算机访问网络延迟越低越好吗,网速和网络延迟(网络延迟取决于什么)
- Android手势密码
- Zookeeper+Hadoop+Hbase完全分布搭建数据仓库安装部署说明
- bind dlz mysql ptr_Bind+DLZ+MySQL智能DNS的正向解析和反向解析实现方法