Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access RefreshIndicatorState of RefreshIndicator?

The docs for RefreshIndicator suggest you can programmatically trigger the refresh behaviour via the RefreshIndicatorState class.

How do I access an instance of this class, assuming I've added a RefreshIndicator widget to my application? I can't see a property to access it and I'm assuming createState() is only used by the Flutter framework.

To avoid an XY problem, I should explain my reason for doing this is to perform a visually pleasing refresh of my list when my user first opens the app. The list will be empty initially and the refresh will poll my server for data.

like image 710
Duncan Jones Avatar asked Oct 21 '25 13:10

Duncan Jones


1 Answers

See https://docs.flutter.io/flutter/material/RefreshIndicatorState/show.html and a usage example in the Flutter Gallery

Essentially

var indicator = new GlobalKey<RefreshIndicatorState>();

and then

indicator.currentState.show();

after it's built.

like image 116
xster Avatar answered Oct 24 '25 14:10

xster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!