Skip to content
Back to skills

Flutter Context Watch Instead Of Top Builder

ASecurity

Refactors Flutter widgets to replace top-level BlocBuilder wrappers with context.watch-based state reads while preserving behavior. Use when the user asks to remove BlocBuilder at page/widget root, use context.watch, or simplify Flutter BLoC widget trees.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 25, 2026
ai-agentsgorails

Security analysis

A100/100

Scanned September 25, 2026

npx -y skills add leancodepl/ai-plugins --skill flutter-context-watch-instead-of-top-builder --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter Context Watch Instead Of Top Builder?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flutter Context Watch Instead Of Top Builder
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leancodepl-flutter-context-watch-instead-of-top-builder/badge)](https://www.skillsdirectory.com/skills/leancodepl-flutter-context-watch-instead-of-top-builder)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: flutter-context-watch-instead-of-top-builder
description: Refactors Flutter widgets to replace top-level BlocBuilder wrappers with context.watch-based state reads while preserving behavior. Use when the user asks to remove BlocBuilder at page/widget root, use context.watch, or simplify Flutter BLoC widget trees.
---

# Flutter context.watch Instead of Top Builder

## Goal

Replace a top-level `BlocBuilder<Cubit, State>` with `context.watch<Cubit>()` in `build`, while keeping the same UI behavior.

## Workflow

1. Identify a root `BlocBuilder` wrapping most of the screen.
2. Inside `build`, read the cubit once:
   - `final cubit = context.watch<MyCubit>();`
   - `final state = cubit.state;`
3. Remove the outer `BlocBuilder` and return the wrapped widget directly.
4. Keep write actions as `context.read<MyCubit>()` in handlers (`onTap`, submit, etc.).
5. If `presentation` stream listeners exist (for `useOnStreamChange`), use `cubit.presentation` so there is a single watched cubit reference.
6. Validate no behavior changes: loading, list size, buttons, and side effects should match previous logic.

## Guardrails

- Only refactor when the top-level builder is a straightforward state passthrough.
- Do not change business logic, event handling, or navigation.
- Do not introduce extra rebuild scopes accidentally; watch only the cubit needed by this widget.
- Preserve existing analytics IDs and localization usage.

## Example Pattern

```dart
// Before
return BlocBuilder<MyCubit, MyState>(
  builder: (context, state) => MyScaffold(
    isLoading: state.isLoading,
  ),
);
```

```dart
// After
final cubit = context.watch<MyCubit>();
final state = cubit.state;

return MyScaffold(
  isLoading: state.isLoading,
);
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.