Home > Blockchain >  is it possible to do pull to refresh action in empty screen
is it possible to do pull to refresh action in empty screen

Time:04-12

enter image description here

i have this screen with no list of data to show in this empty screen also when i pull down i wanna perform refreshIndicator function but i dont know how to do it. when there is list of data pull to refresh works perfectly fine but if there is not data pull to refresh doesnt work is there a way to achieve pull to refresh in an empty screen like this also. thanks

CodePudding user response:

YOU Can wrap your entire screen with a refreshIndicator, and you get access to the refresh function.

body: RefreshIndicator(
            onRefresh: () async {
              fetchData();
            },
            child:// your other widgets here

CodePudding user response:

Yes, with RefreshIndicator Widget, it's very simple, wrap the whole page in RefreshIndicator Widget, and just keep in mind that you should make the onRefresh function to return Future, because after getting the data, there is 2 things to be handled:

  1. the widget will handle the CircularProgressIndicator just after the onRefresh function gets the data, that is why I used await at the code example, to make the widget know when the function is finished.

  2. you should update the state, like this code, I'm using bloc to update it, you are free to use any stage management else:

    RefreshIndicator(
      onRefresh: () async {
        await _bloc.pull();
      }
      child: .....,
    );
    

For more tutorial check this video.

  • Related