riverpod-cancel

Cancel and debounce Riverpod async requests using ref.onDispose callbacks.

Updated Apr 1, 2026
One-click install
npx skills add https://github.com/chetan2921/flo --skill riverpod-cancel-chetan2921
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: riverpod-cancel
Source: https://github.com/chetan2921/flo/tree/main/.github/skills/riverpod-cancel
Command: npx skills add https://github.com/chetan2921/flo --skill riverpod-cancel-chetan2921

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of managing in-flight asynchronous requests in Riverpod by enabling automatic cancellation and debouncing, preventing unnecessary resource consumption or race conditions.

Core Features & Use Cases

  • Request Cancellation: Cancel ongoing requests when a user leaves a page or component, conserving resources.
  • Debouncing: Delay multiple rapid refresh triggers to avoid redundant requests, improving performance.
  • Use Case: When building a data-heavy dashboard, debounce user-triggered data refreshes and cancel outdated requests upon navigation to ensure smooth user experience.

Quick Start

Use the riverpod-cancel skill to properly handle request cancellation and debouncing patterns in your Flutter project.

Frequently Asked Questions about riverpod-cancel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I cancel in-flight async requests in Riverpod when a user leaves a page?

To cancel async requests in Riverpod, utilize ref.onDispose callbacks to safely terminate ongoing requests upon navigation. This prevents stale data retrieval and conserves resources when users leave a page or component.

What is the best way to debounce rapid refresh triggers in a Flutter app?

Debouncing rapid refresh triggers in a Flutter app involves implementing delay logic within Riverpod providers. This delays multiple rapid triggers to avoid redundant requests, improving overall app performance.

Why does my Riverpod state update with stale data during rapid user interactions?

Riverpod state updates with stale data during rapid interactions due to race conditions between overlapping async requests. Applying automatic request cancellation ensures outdated fetches are terminated when new triggers occur.

Can I use ref.onDispose to manage async request lifecycle in Flutter?

Yes, you can use ref.onDispose to manage the async request lifecycle in Flutter. It provides a reliable callback mechanism to safely cancel ongoing requests and free resources when a provider is disposed.

How do I optimize resource use in a data-heavy Flutter dashboard with Riverpod?

Optimizing resource use in a data-heavy Flutter dashboard requires canceling outdated requests upon navigation and debouncing user-triggered refreshes. This prevents unnecessary resource consumption and ensures a smooth user experience.