简体   繁体   中英

My wallet refuses to display balance after updating firebase

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文简体   中文繁体   中英对照 版本,有任何建议请联系yoyou2525@163.com。

After updating this line in Future builder

Container(
  child: FutureBuilder<DocumentSnapshot>(
    future: FirebaseFirestore.instance
        .collection("users")
        .doc(RitechApp.sharedPreferences
        .getString(RitechApp.userUID))
        .get(),
    builder: (c, snapshot) {
      if (!snapshot.hasData)
        return Center(
          child: CircularProgressIndicator(
            valueColor:
            new AlwaysStoppedAnimation<Color>(
                kPrimaryColor),
          ),
        );
      else {
        return Text(
          "KES" +
              snapshot..data.data["Wallet"]
                  .toString() ??
              0.toString(),
          style: TextStyle(
              fontSize: 25,
              fontFamily: "Muli",
              color: Colors.white),
        );
      }
    },
  ),
),

This following firebase database update and as well as observing null safety rules, I'm unable to retrieve wallet balance or update with each transaction. This is the code:

Container(
  child: FutureBuilder<DocumentSnapshot>(
    future: FirebaseFirestore.instance
        .collection("users")
        .doc(RitechApp.sharedPreferences
            .getString(RitechApp.userUID))
        .get(),
    builder: (c, snapshot) {
      if (!snapshot.hasData)
        return Center(
          child: CircularProgressIndicator(
            valueColor:
                new AlwaysStoppedAnimation<Color>(kPrimaryColor),
          ),
        );
      else {
        return Text(
          "KES" + snapshot.data!["Wallet"].toString() ??
              0.toString(),
          style: TextStyle(
              fontSize: 25,
              fontFamily: "Muli",
              color: Colors.white),
        );
      }
    },
  ),
),

I'm unable to retrieve wallet balance or update with each transaction. This is the code.

1 anwsers

Create a state variable for future like

  late final myFuture = FirebaseFirestore.instance
      .collection("users")
      .doc(RitechApp.sharedPreferences.getString(RitechApp.userUID))
      .get();

and use FutureBuiler like this, you will get error message if something fails

child: FutureBuilder<DocumentSnapshot?>(
  future: myFuture,
  builder: (c, snapshot) {
    if (snapshot.hasData) {
     // 
      return Text(
        // "KES ${snapshot.data?["Wallet"] ?? 0} ",
         "KES ${snapshot.data?.get("Wallet") ?? 0}",
        style: TextStyle(
            fontSize: 25, fontFamily: "Muli", color: Colors.white),
      );
    } else if (snapshot.hasError) {
      return Text(" ${snapshot.error}");
    } else {
      return Center(
        child: CircularProgressIndicator(
          valueColor: new AlwaysStoppedAnimation<Color>(Colors.red),
        ),
      );
    }
  },
),
6 GUPSHUP endpoint for Wallet balance

Is there an endpoint in API that will return the Wallet balance in U$ in the GUPshup? I need to check the balance, without having to enter Gupshup. ...

2021-03-03 11:44:55 1 58   gupshup
9 Kucoin API wallet balance

I am trying to check my Spot account balance using the Kucoin API, get_accounts().(Github: Link) And although on github and API documentation get_acco ...

暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM