首页 > 解决方案 > 无法在颤动中显示图标 onTap

问题描述

每当调用 ontap 函数时,我都试图在文本上显示一个图标。

onTap: () {
                                if (cellStatus['$j$k'] ?? true) {
                                  print('working');
                                  setState(() {
                                    cellStatus.addAll({'$j$k': false});
                                    Icon(Icons.access_alarm);
                                  });
                                }
                              },

我哪里错了。。

标签: arraysflutterdart

解决方案


在您的小部件内部

            InkWell(
               onTap:(){
                  setState(() {
                                cellStatus['$j$k'] = true;
                              });
               } ,
                 
           child: !cellStatus['$j$k'] ? Text("example text") : 
                  Icon(Icons.access_alarm) ,
              
             ),

推荐阅读