公司网站设计与实现的项目建议书,汕头h5建站模板,网站开发总监待遇,网站建设服务上海文章目录 问题描述错误源码 问题分析解决方法修改后的代码 问题描述
今天有个同事调试flutter程序时报错#xff0c;问我怎么解决#xff0c;程序运行时报如下错误#xff1a; type ‘Future’ is not a subtype of type ‘int’ in type cast 错误源码 int order Databas… 文章目录 问题描述错误源码 问题分析解决方法修改后的代码 问题描述
今天有个同事调试flutter程序时报错问我怎么解决程序运行时报如下错误 type ‘Future’ is not a subtype of type ‘int’ in type cast 错误源码 int order DatabaseHelper.dbhelper.getTaskGroupRelationOrder() as int;TaskGroupRelation relation TaskGroupRelation(id:0,taskId:snapshot.data?[index].id,groupId:widget.groupId,taskOrder:order,);DatabaseHelper.dbhelper.insertTaskGroupRelationData(relation);if (context.mounted) Navigator.of(context).pop();问题分析
类型“Futureint”不是类型强制转换中类型“int”的子类型。这里不能强制转换要拿到DatabaseHelper.dbhelper.getTaskGroupRelationOrde()返回结果可以使用DatabaseHelper.dbhelper.getTaskGroupRelationOrder().then((value) {})
解决方法
使用DatabaseHelper.dbhelper.getTaskGroupRelationOrder().then((value) {})
修改后的代码 TaskGroupRelation relation;DatabaseHelper.dbhelper.getTaskGroupRelationOrder().then((value) {relation TaskGroupRelation(id:0,taskId:snapshot.data?[index].id,groupId:widget.groupId,taskOrder:value,),DatabaseHelper.dbhelper.insertTaskGroupRelationData(relation),if (context.mounted) Navigator.of(context).pop(),});结束语 Flutter是一个由Google开发的开源UI工具包它可以让您在不同平台上创建高质量、美观的应用程序而无需编写大量平台特定的代码。我将学习和深入研究Flutter的方方面面。从基础知识到高级技巧从UI设计到性能优化欢饮关注一起讨论学习共同进入Flutter的精彩世界