Skip to content
Back to skills

Flutter Performance

ASecurity

The issue is that the cart count change is coupled to the whole page state, so the expensive product grid rebuilds too. Fix it by isolating the header update from the grid: - Do not call `setState()` at the page/root level for cart count changes. - Put the cart badge/header in its own `BlocBuilder` with `buildWhen`, or use `context.select()` / `BlocSelector` so only the count widget rebuilds. - Keep the product grid as a separate widget with stable inputs; make static children `const` where p...

  • 584 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
development

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-performance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter Performance?

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

Security grade badge for Flutter Performance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-flutter-performance-72aa9936/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-performance-72aa9936)

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
The issue is that the cart count change is coupled to the whole page state, so the expensive product grid rebuilds too.

Fix it by isolating the header update from the grid:

- Do not call `setState()` at the page/root level for cart count changes.
- Put the cart badge/header in its own `BlocBuilder` with `buildWhen`, or use `context.select()` / `BlocSelector` so only the count widget rebuilds.
- Keep the product grid as a separate widget with stable inputs; make static children `const` where possible.
- If the grid is visually heavy, wrap it in `RepaintBoundary` so header changes do not trigger unnecessary repaints.
- Make sure any sorting/filtering work is outside `build()`.

Example:

```dart
class ShopPage extends StatelessWidget {
  const ShopPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: const [
        _CartHeader(),
        Expanded(child: RepaintBoundary(child: ProductGrid())),
      ],
    );
  }
}

class _CartHeader extends StatelessWidget {
  const _CartHeader();

  @override
  Widget build(BuildContext context) {
    final itemCount = context.select((CartBloc bloc) => bloc.state.itemCount);
    return HeaderCartBadge(count: itemCount);
  }
}
```

If using `BlocBuilder`, make it granular:

```dart
BlocBuilder<CartBloc, CartState>(
  buildWhen: (prev, next) => prev.itemCount != next.itemCount,
  builder: (context, state) => HeaderCartBadge(count: state.itemCount),
)
```

Main takeaway: rebuild only the cart-count widget, not the whole screen or product grid.

Files in this skill

  • eval-1.baseline.md472 B
  • eval-1.with-skill.md795 B
  • eval-2.baseline.md924 B
  • eval-2.with-skill.md1.5 KB
  • eval-3.baseline.md1 KB
  • eval-3.with-skill.md1.2 KB
  • trigger-1.md184 B
  • trigger-2.md211 B
  • trigger-3.md206 B
  • trigger-4.md232 B
  • trigger-5.md189 B

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 development →

Comments

Loading comments…

Newsletter

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