skills/flutter/flutter-ui/SKILL.md
Build performant, accessible UIs with strict design tokens and reusable widget patterns. Use when implementing layouts, responsive breakpoints, theming, widget extraction, or fixing common rendering issues like overflow errors.
npx skillsauth add dhruvanbhalara/skills flutter-uiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
const MUST be const.SliverList.builder or SliverGrid.builder for lists > 10 items.RepaintBoundary.compute() or Isolate for JSON > 1MB.mounted before using context across async gaps.Use AppColors, AppSpacing, AppRadius, and AppTypography. NEVER hardcode raw values.
context.colorScheme.primary or AppColors. Support light/dark modes.AppSpacing.sm (8), AppSpacing.md (16), etc. Use SizedBox for gaps.AppRadius.md (12) for consistent rounding.context.textTheme.bodyMedium. Support text scaling.core/views/widgets.Key('feature_action_id') to interactive widgets for test access._build*() methods. Extract into separate widget classes.CustomScrollView with Slivers for non-trivial scrollable layouts.Scaffold screens over ModalBottomSheet for complex forms.600-840dp) and desktop (>840dp). Use MediaQuery.sizeOf(context).width.LayoutBuilder when widget rendering depends on the immediate parent's constraints, not the whole screen.SafeArea to avoid device notches and system UI.A RenderFlex overflowed...: Typically means a widget is demanding more space than available in a Row or Column. Wrap the offending widget in Expanded or Flexible.Vertical viewport was given unbounded height: Often happens when nesting scrollable views (like ListView inside Column). Use Expanded on the ListView or set shrinkWrap: true.| Tool | Use When | Returns |
|---|---|---|
| MediaQuery.sizeOf(context) | Layout depends on screen size (app-level breakpoints) | Size of the screen |
| LayoutBuilder | Layout depends on parent constraints (widget-level) | BoxConstraints from parent |
Rule: Use MediaQuery for page-level layouts. Use LayoutBuilder for reusable components that adapt to their container.
| Window Class | Width | Layout | Columns | |---|---|---|---| | Compact | < 600dp | Single column, bottom nav | 4 | | Medium | 600–840dp | Two-pane, navigation rail | 8 | | Expanded | > 840dp | Multi-pane, side navigation | 12 |
Widget build(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
return switch (width) {
< 600 => const MobileLayout(),
< 840 => const TabletLayout(),
_ => const DesktopLayout(),
};
}
| Widget | Behavior | Use When |
|---|---|---|
| Expanded | Fill ALL remaining space in Row/Column | Child should stretch |
| Flexible | Allow child to be SMALLER than remaining space | Child has natural size |
| FractionallySizedBox | Size as fraction of parent (e.g., 0.5 = 50%) | Proportional layouts |
| ConstrainedBox | Set min/max constraints | Bounded flexibility |
| SizedBox | Fixed absolute dimensions | Known exact size |
Semantics labels. Ensure 48x48 dp touch targets. WCAG AA contrast.development
Perform REST API networking operations (GET, POST, PUT, DELETE) using the lightweight and robust standard `http` package, including platform configurations and background parsing models.
development
Configure internationalization and localization support using Flutter's built-in l10n system, App Resource Bundle (ARB) files, and ICU formatting syntax.
development
Create model classes with fromJson/toJson using dart:convert and Dart 3 pattern matching. Use when manually mapping JSON to classes, parsing HTTP responses, or choosing between manual and code-generated serialization.
data-ai
Diagnose and fix Flutter layout constraint violations (RenderFlex overflow, unbounded height/width, ParentData misuse). Use when encountering layout exceptions, yellow-black overflow stripes, or red error screens.