riverpod-cancel

Cancel and debounce Riverpod asynchronous requests with auto-dispose providers.

8|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/serverpod/skills-registry --skill riverpod-cancel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: riverpod-cancel
Source: https://github.com/serverpod/skills-registry/tree/main/skills/riverpod/riverpod-cancel
Command: npx skills add https://github.com/serverpod/skills-registry --skill riverpod-cancel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps manage asynchronous operations in Riverpod, preventing resource leaks and improving user experience by cancelling or debouncing requests when they are no longer needed.

Core Features & Use Cases

  • Cancel In-flight Requests: Automatically cancel ongoing network requests or long-running computations when a user navigates away from a page or component.
  • Debounce Rapid Refreshes: Prevent excessive API calls by delaying execution until a short period of inactivity, useful for search inputs or real-time updates.
  • Use Case: When a user rapidly clicks a refresh button multiple times, this skill ensures only one request is actually sent after a brief pause, and if the user navigates away before the request completes, it's automatically cancelled.

Quick Start

Use the riverpod-cancel skill to ensure that any ongoing async requests are cancelled when the associated provider is disposed.

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 Riverpod async requests when a user navigates away in Flutter?

Cancel in-flight Riverpod async requests by using auto-dispose providers alongside ref.onDispose, which automatically terminates ongoing network calls or computations when the associated widget is disposed.

What's the best way to debounce rapid Riverpod provider refreshes for search inputs?

Debounce rapid Riverpod provider refreshes by delaying execution until a brief period of inactivity occurs, preventing excessive API calls during rapid UI updates like typing in a search input.

Why does Riverpod leave asynchronous operations running after widget disposal?

Riverpod leaves asynchronous operations running after disposal because standard providers lack automatic cancellation, requiring ref.onDispose and auto-dispose providers to clean up in-flight operations and prevent resource leaks.

Can I use auto-dispose providers to manage Flutter state cleanup for long-running tasks?

Yes, you can use auto-dispose providers to manage Flutter state cleanup for long-running tasks, as they automatically trigger cancellation logic through ref.onDispose when the provider is no longer being listened to.

How do I prevent excessive API calls when a user rapidly clicks a refresh button in Flutter?

Prevent excessive API calls from rapid refresh button clicks by applying debouncing logic to your Riverpod providers, ensuring only one request executes after a brief pause in user activity.

Do I need additional dependencies to manage cancellation and debouncing in Riverpod?

No, you do not need additional dependencies to manage cancellation and debouncing in Riverpod, as the implementation relies entirely on built-in mechanisms like ref.onDispose and auto-dispose providers.