Flutter show's a red error screen before loading data from firebase using StreamBuilder, how to fix?

后端 未结 2 577
悲哀的现实
悲哀的现实 2021-01-24 10:36

I am getting data from firebase and making cards using that data. to display certain data of user from database, the data loads fine but for 1 second or more there is a red err

2条回答
  •  长情又很酷
    2021-01-24 11:09

    you can show a progress indicator as your load your data as shown below

    return StreamBuilder(
        stream: Firestore.instance.collection(UserInformation).document(user.uid).snapshots(),
        builder: (context, snapshot) {
        //==========show progress============
         if (!snapshot.hasData) {
            return CircularProgressIndicator()            
          }
          var userDocument = snapshot.data;
          // User userDocument here ..........
    

提交回复
热议问题