I know with a ListView or SingleChildScrollView RefreshIndicator just works natively but I want to use a RefreshIndicator
Recommend using AlwaysScrollableScrollPhysics() with RefreshIndicator because If the Scrollable might not have enough content to over-scroll, consider settings its physics property to AlwaysScrollableScrollPhysics.
Instead of creating your own subclasses, parent can be used to combine ScrollPhysics objects of different types to get the desired scroll physics. For example:
ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: ...
)
Note : A RefreshIndicator can only be used with a vertical scroll view.
In ListView.builder use physics: AlwaysScrollableScrollPhysics()
Example:
RefreshIndicator(
onRefresh: () => _onRefresh(),
child: Center(
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
controller: _scrollController,
itemCount: 4,
addAutomaticKeepAlives: true,
itemBuilder: (BuildContext context, int position) {
return Text("Hello $position");
}
),
),
)