首页 > 其他分享 >Flutter开发type 'Null' is not a subtype of type 'Handler'报错

Flutter开发type 'Null' is not a subtype of type 'Handler'报错

时间:2023-12-01 18:31:36浏览次数:25  
标签:value subtype dbhelper 报错 DatabaseHelper type Flutter relation

在这里插入图片描述

问题描述

今天调试flutter程序时报错,程序运行时报如下错误: type 'Null' is not a subtype of type 'Handler'

image.png

问题分析

类型“Future<int>”不是类型强制转换中类型“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(),
                            });

<center>结束语</center> Flutter是一个由Google开发的开源UI工具包,它可以让您在不同平台上创建高质量、美观的应用程序,而无需编写大量平台特定的代码。我将学习和深入研究Flutter的方方面面。从基础知识到高级技巧,从UI设计到性能优化,欢饮关注一起讨论学习,共同进入Flutter的精彩世界!

标签:value,subtype,dbhelper,报错,DatabaseHelper,type,Flutter,relation
From: https://blog.51cto.com/u_15777557/8648537

相关文章