RefreshTrigger constructor

const RefreshTrigger({
  1. Key? key,
  2. double? minExtent,
  3. double? maxExtent,
  4. FutureVoidCallback? onRefresh,
  5. Axis direction = Axis.vertical,
  6. bool reverse = false,
  7. RefreshIndicatorBuilder? indicatorBuilder,
  8. Curve? curve,
  9. Duration? completeDuration,
  10. 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 capability
  • onRefresh (FutureVoidCallback?, optional): Async callback triggered on refresh
  • direction (Axis, default: Axis.vertical): Pull gesture direction
  • reverse (bool, default: false): Whether to trigger from opposite direction
  • minExtent (double?, optional): Minimum pull distance to trigger refresh
  • maxExtent (double?, optional): Maximum allowed pull distance
  • indicatorBuilder (RefreshIndicatorBuilder?, optional): Custom indicator widget builder
  • curve (Curve?, optional): Animation curve for refresh transitions
  • completeDuration (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,
});