riverpod-auto-dispose

Implement Riverpod auto-dispose provider lifecycle management with ref.keepAlive(), ref.onDispose(), and ref.invalidate().

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers manage Riverpod provider lifecycles efficiently by enabling automatic disposal of providers with no listeners, reducing memory leaks and resource consumption.

Core Features & Use Cases

  • Automatic disposal of providers when they have no active listeners, ensuring optimized memory use.
  • Control over provider lifecycle through ref.keepAlive(), ref.onDispose(), and ref.invalidate().
  • Use case: Developers can use this Skill to prevent memory bloat in Flutter apps by automatically cleaning up providers that are no longer in use, especially in large or complex projects with many providers.

Quick Start

Use the skill to implement auto-dispose logic in your Riverpod providers to automatically release resources when they are no longer needed.

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 Flutter Riverpod providers?

Preventing memory leaks in Flutter Riverpod providers involves using auto-dispose to automatically remove providers lacking active listeners. This mechanism ensures efficient resource cleanup and reduces memory bloat in applications.

What is the best way to manage Riverpod provider lifecycle and cleanup?

The best way to manage Riverpod provider lifecycle is by using auto-dispose features alongside lifecycle control methods like ref.keepAlive(), ref.onDispose(), and ref.invalidate() to ensure proper resource cleanup and invalidation.

How does auto-dispose work in Riverpod state management?

Auto-dispose in Riverpod state management works by automatically destroying providers when they no longer have any active listeners. This lifecycle control ensures efficient resource use and prevents memory bloat within Dart applications.

When should I use ref.keepAlive to control provider disposal in Flutter?

Use ref.keepAlive to control provider disposal in Flutter when you need to override the default auto-dispose behavior and keep a provider alive even without active listeners. This manages resource cleanup during complex navigation.

Can I use Riverpod auto-dispose for large Flutter projects with many providers?

Yes, you can use Riverpod auto-dispose for large Flutter projects with many providers. It is specifically useful for preventing memory bloat by automatically cleaning up providers that are no longer in use across complex project architectures.