flutter-smell-mounted-checks

Detect mounted checks and setState-after-await smells in Flutter UI.

Updated Nov 7, 2025
One-click install
npx skills add https://github.com/belluga/delphi-ai --skill flutter-smell-mounted-checks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-smell-mounted-checks
Source: https://github.com/belluga/delphi-ai/tree/main/.cline/skills/flutter-smell-mounted-checks
Command: npx skills add https://github.com/belluga/delphi-ai --skill flutter-smell-mounted-checks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flutter UI often suffers from lifecycle-related defects when asynchronous work is performed. This includes checks of mounted/context.mounted, performing setState after an await, or navigating after asynchronous gaps, which can cause crashes, memory leaks, or inconsistent UI state. This Skill formalizes the detection and root-cause analysis of these smells and provides refactor guidance.

Core Features & Use Cases

  • Detect signals such as if (!mounted) / if (!context.mounted)
  • Detect setState after an await
  • Detect Navigator calls after async gaps in UI
  • Provide root-cause questions and the preferred fixes in order
  • Document acceptable exceptions and log every accepted exception to a project artifact

Quick Start

Scan the current Flutter UI for mounted/context.mounted signals, setState-after-await, and navigation after awaits, then apply the provided root-cause fixes.

Frequently Asked Questions about flutter-smell-mounted-checks

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

FAQPage Schema
How do I fix setState after an async call in Flutter?

To fix setState after an async call in Flutter, you should move the asynchronous work to controllers, cancel timers during disposal, or replace setState with reactive updates to avoid lifecycle defects.

Why does Flutter require mounted checks before updating the UI?

Flutter requires mounted checks before updating the UI because widgets can be disposed during asynchronous gaps, and updating an unmounted widget causes crashes, memory leaks, or inconsistent UI state.

How do I detect and refactor navigation after async gaps in Flutter?

You can detect navigation after async gaps in Flutter by scanning for Navigator calls following await statements, then applying root-cause analysis to move navigation logic or verify context.mounted before proceeding.

What is the best way to handle widget lifecycle ownership during Flutter async operations?

The best way to handle widget lifecycle ownership during Flutter async operations is moving async work to controllers, canceling disposal tasks, or replacing setState with reactive updates rather than relying on mounted checks.

Can I use context.mounted instead of mounted for async navigation in Flutter?

You can use context.mounted instead of mounted for async navigation in Flutter, but the preferred approach is moving the navigation logic out of the widget, canceling disposal, or applying reactive updates to eliminate the smell entirely.

Are there any exceptions where mounted checks are acceptable in Flutter development?

Exceptions where mounted checks are acceptable in Flutter development exist, but every accepted exception must be documented and logged to a project artifact during auditing or refactoring to maintain code quality.