RefreshTrigger constructor
const
RefreshTrigger({
- Key? key,
- double? minExtent,
- double? maxExtent,
- FutureVoidCallback? onRefresh,
- Axis direction = Axis.vertical,
- bool reverse = false,
- RefreshIndicatorBuilder? indicatorBuilder,
- Curve? curve,
- Duration? completeDuration,
- required Widget child,
Creates a RefreshTrigger with pull-to-refresh functionality.
Wraps the provided child widget with refresh gesture detection and visual indicator management.
Parameters:
child
(Widget, required): Scrollable content to wrap with refresh capabilityonRefresh
(FutureVoidCallback?, optional): Async callback triggered on refreshdirection
(Axis, default: Axis.vertical): Pull gesture directionreverse
(bool, default: false): Whether to trigger from opposite directionminExtent
(double?, optional): Minimum pull distance to trigger refreshmaxExtent
(double?, optional): Maximum allowed pull distanceindicatorBuilder
(RefreshIndicatorBuilder?, optional): Custom indicator widget buildercurve
(Curve?, optional): Animation curve for refresh transitionscompleteDuration
(Duration?, optional): Duration of completion animation
The onRefresh
callback should return a Future that completes when the
refresh operation is finished. During this time, a loading indicator will be shown.
Example:
RefreshTrigger(
onRefresh: () async {
final newData = await fetchDataFromAPI();
setState(() => items = newData);
},
minExtent: 60,
direction: Axis.vertical,
child: ListView(children: widgets),
)
Implementation
const RefreshTrigger({
super.key,
this.minExtent,
this.maxExtent,
this.onRefresh,
this.direction = Axis.vertical,
this.reverse = false,
this.indicatorBuilder,
this.curve,
this.completeDuration,
required this.child,
});