riverpod-auto-dispose

Automatically dispose Riverpod providers when they have no listeners.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps manage the lifecycle of Riverpod providers, ensuring resources are cleaned up efficiently and preventing memory leaks by automatically disposing of providers when they are no longer in use.

Core Features & Use Cases

  • Automatic Disposal: Providers are automatically destroyed when they have no listeners.
  • Resource Management: Clean up resources (like StreamControllers) when a provider is disposed.
  • State Caching Control: Prevent memory leaks by managing provider state, especially for family providers.
  • Use Case: When working with a complex application state managed by Riverpod, this skill ensures that components that are no longer visible or interacting with a provider do not continue to consume memory or perform unnecessary computations.

Quick Start

Use the riverpod-auto-dispose skill to enable automatic disposal for the myProvider.

Frequently Asked Questions about riverpod-auto-dispose

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

FAQPage Schema
How do I prevent memory leaks in Riverpod providers?

To prevent memory leaks in Riverpod, you can use automatic disposal to destroy providers when they have no active listeners, ensuring efficient resource cleanup and controlled state caching.

How does auto-dispose work for Riverpod provider lifecycles?

Auto-dispose manages Riverpod provider lifecycles by automatically destroying providers based on listener count and lifecycle events, deallocating resources and stopping unnecessary computations when components are no longer visible.

How do I clean up StreamControllers when a Riverpod provider is disposed?

You clean up StreamControllers during Riverpod provider disposal by utilizing automatic lifecycle management, which triggers resource cleanup and prevents memory leaks when the provider loses all listeners.

What is the best way to manage state caching for Riverpod family providers?

The best way to manage state caching for Riverpod family providers is through automatic disposal, which controls state retention and prevents memory leaks by destroying providers when they are no longer in use.

Does automatic disposal stop unnecessary computations in Dart applications?

Yes, automatic disposal stops unnecessary computations in Dart applications by destroying Riverpod providers when components are no longer interacting with them, ensuring efficient resource deallocation and dynamic state management.