CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

thiennc-tesoglobal/flutter-skills

Focused Agent Skills for complete Flutter and Dart app delivery.

Quality

88%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

async-state-patterns.mdskills/flutter-state-management/references/

Async State Patterns

Modeling async state correctly ensures the UI stays predictable during data fetches, handles errors gracefully, and avoids impossible logic states.

Sealed Result and AsyncValue vs. Booleans

  • Use sealed classes, AsyncValue (Riverpod), or algebraic data types instead of loose boolean flags (isLoading, hasError).
  • Loose booleans can lead to impossible combinations (e.g., isLoading = true AND hasError = true AND data != null), confusing the UI layer. Sealed hierarchies enforce mutually exclusive, well-defined states.
  • When using Riverpod's AsyncValue, wrap the async body in AsyncValue.guard rather than hand-written try/catch into AsyncLoading/AsyncError/AsyncData. It preserves the previous value for optimistic UI and captures stack traces consistently.

State Modeling

Clearly delineate these standard async states where the UI needs them:

  1. Initial / Empty: No data yet, no fetch initiated.
  2. Loading: Fetch in progress. Distinguish between first-time loading and background refreshing if necessary.
  3. Success: Data fetched and ready to display.
  4. Error: Fetch failed. Store the error and stack trace for logging or display.

Error Recovery and Retry

  • Ensure error states expose enough information to allow the user to retry the operation.
  • Implement explicit transitions back to Loading from Error when a retry is triggered, preventing the UI from being permanently stuck in an error state.

Preventing Impossible Combinations

  • Do not use overlapping boolean properties.
  • Do not let successful data remain populated in a way that conflicts with a new loading or error state unless you explicitly model an "updating with previous data" state.
  • Validate that the chosen architecture forces the compiler to check exhaustive state handling (e.g., using exhaustive switch on sealed classes).

skills

LICENSE

README.md

tile.json