flutter 未定义的名称“title”,(文档)

l3zydbqr  于 2023-01-14  发布在  Flutter
关注(0)|答案(2)|浏览(135)

hii我是新的Flutter和面临以下错误

final String title;
final String desc;
final String timer;
const ListElement({Key? key, required this.title, required this.desc ,required this.timer}) : 
super(key: key);

这是我的构造函数,我在其中传递了title desc和timer

Text(title, style: TextStyle(fontWeight: FontWeight.w400 ,
                  fontSize: 30),),
 Text(desc, style: TextStyle(fontWeight: FontWeight.w400 ,
                  fontSize: 15),),

获取标题和说明时遇到此错误

ni65a41a

ni65a41a1#

如果小部件是stateful,则必须将title写为

Text(widget.title, style: .......
xxslljrj

xxslljrj2#

确定,我使用“${widget.title}”来解决此问题

相关问题