首页 > 解决方案 > 颤振显示专业徽章的火力基地人物

问题描述

我正在尝试在我的应用中订阅的用户名旁边显示专业徽章。然而,我的方法导致所有用户都拥有专业徽章,即使是那些未订阅的用户。

这是我的逻辑

//function checking firebase if user is pro

    checkfirebasepro(var ownerid)async{
    
       await FirebaseFirestore.instance
            .collection('users')
            .doc(ownerid)
    
            .get()
            .then((prostatus) {
          if (prostatus.data()["isPro"]==true) {
            setState(() { isprouser=true;
    
            });
          } else {
            isprouser=false;
          }
        });
    
      }

然后在调用上述函数后在我的 listview.builder 中,这是我如何尝试为专业用户显示专业徽章

 isprouser ==true?Container(
                                                    height: 15,
                                                    width: 33,
                                                    child: Center(
                                                        child: Text(
                                                          "PRO",
                                                          style: TextStyle(
                                                            fontSize: 11,
                                                              fontWeight: FontWeight.bold,
                                                              color: Colors.black),
                                                        )),
                                                    decoration: BoxDecoration(
                                                        color: kGoldColor,
                                                        borderRadius: BorderRadius.circular(4)),
                                                  ):Text("")

标签: flutter

解决方案


推荐阅读