1

I want to shown progress dialog again on refresh button means want to refresh FutureBuilder.No progress dialog is showing on refresh button.

FutureBuilder<UserReviewedResponse>(
                      future: request,
                      builder:
                          (context, AsyncSnapshot<UserReviewedResponse> snapshot) {
                        if (snapshot.hasData) {
                          return buildList(snapshot);
                        } else if (snapshot.hasError) {
                          return Text(snapshot.error.toString());
                        }
                        return progressBar();
                      },

Refresh button onTap() code

 Widget buildList(AsyncSnapshot<UserReviewedResponse> snapshot) {
    // Log.e("snapshot.data.data.length",snapshot.data.data.length);
    if (snapshot.data.statusCode == 200) {
      if(snapshot.data.body.length>0){
        return ListView.builder(
            scrollDirection: Axis.vertical,
            physics: AlwaysScrollableScrollPhysics(),
            shrinkWrap: true,
            itemCount: snapshot.data.body.length,
            itemBuilder: (BuildContext context, int index) {
              return item( snapshot,index);
            });
      }else{
        return Container(
          height: SizeConfig.screenHeight,
          width: SizeConfig.screenWidth,
          padding: EdgeInsets.fromLTRB(0, 0, 0, 60),
          child: Center(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: [
                Text('No account for review',
                  style: TextStyle(fontFamily: 'semibold',fontSize: 18),
                  textAlign: TextAlign.center,),
                Container(
                  width: 200,
                  padding: EdgeInsets.all(10),
                  child: Material(
                    color: Colors.transparent, // button color
                    child: InkWell(
                      splashColor: Colors.grey[200], // splash color
                      onTap: () {
                        setState(() {
                          request=null;
                        });
                        NetworkCheck.checkConnection(context).then((onValue) {
                          if (onValue) {
                            request = apiProvider.userReviewedListService(WebConstant.REVIEW_LIST,"0","0","10");
                            setState(() {
                              request;
                            });
                          }
                        });

                      }, // button pressed
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Icon(Icons.refresh), // icon
                          Text("Refresh"), // text
                        ],
                      ),
                    ),
                  ),
                )
              ],
            ),
          ),
        );
      }

    } else {
      return Container(
        height: SizeConfig.screenHeight,
        width: SizeConfig.screenWidth,
        padding: EdgeInsets.fromLTRB(0, 0, 0, 60),
        child: Center(
          child: Text('${snapshot.data.message}',
            style: TextStyle(fontFamily: 'semibold'),
            textAlign: TextAlign.center,),
        ),
      );
    }
  }

enter image description here

Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105

0 Answers0