.agents/skills/flutter-adaptive-ui/SKILL.md
Build adaptive and responsive Flutter UIs that work beautifully across all platforms and screen sizes. Use when creating Flutter apps that need to adapt layouts based on screen size, support multiple platforms including mobile tablet desktop and web, handle different input devices like touch mouse and keyboard, implement responsive navigation patterns, optimize for large screens and foldables, or use Capability and Policy patterns for platform-specific behavior.
npx skillsauth add szeyu/open-ssyok-finance flutter-adaptive-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.
Create Flutter applications that adapt gracefully to any screen size, platform, or input device. This skill provides comprehensive guidance for building responsive layouts that scale from mobile phones to large desktop displays while maintaining excellent user experience across touch, mouse, and keyboard interactions.
Core Layout Rule: Constraints go down. Sizes go up. Parent sets position.
3-Step Adaptive Approach:
Key Breakpoints:
Follow the 3-step approach to make your app adaptive.
Identify widgets that need adaptability and extract common data. Common patterns:
For navigation, create a shared Destination class with icon and label used by both NavigationBar and NavigationRail.
Choose the right measurement tool:
MediaQuery.sizeOf(context) - Use when you need app window size for top-level layout decisions
MediaQuery.of() for size queriesLayoutBuilder - Use when you need constraints for specific widget subtree
BoxConstraintsExample:
// For app-level decisions
final width = MediaQuery.sizeOf(context).width;
// For widget-specific constraints
LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth < 600) {
return MobileLayout();
}
return DesktopLayout();
},
)
Apply breakpoints to select appropriate UI. Don't base decisions on device type - use window size instead.
Example breakpoints (from Material guidelines):
class AdaptiveLayout extends StatelessWidget {
@override
Widget build(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
if (width >= 840) {
return DesktopLayout();
} else if (width >= 600) {
return TabletLayout();
}
return MobileLayout();
}
}
Flutter layout follows one rule: Constraints go down. Sizes go up. Parent sets position.
Widgets receive constraints from parents, determine their size, then report size up to parent. Parents then position children.
Key limitation: Widgets can only decide size within parent constraints. They cannot know or control their own position.
For detailed examples and edge cases, see layout-constraints.md.
Row/Column
Row arranges children horizontallyColumn arranges children verticallymainAxisAlignment and crossAxisAlignmentExpanded to make children fill available space proportionallyContainer
Expanded/Flexible
Expanded forces child to use available spaceFlexible allows child to use available space but can be smallerflex parameter to control proportionsFor complete widget documentation, see layout-basics.md and layout-common-widgets.md.
Break down widgets
const widgetsDesign to platform strengths
Solve touch first
Never lock orientation
Avoid device type checks
Platform.isIOS, Platform.isAndroid for layout decisionsUse breakpoints, not orientation
OrientationBuilder for layout changesMediaQuery.sizeOf or LayoutBuilder with breakpointsDon't fill entire width
GridView or flex patternsSupport multiple inputs
For complete best practices, see adaptive-best-practices.md.
Separate what your code can do from what it should do.
Capabilities (what code can do)
Policies (what code should do)
// Capability class
class Capability {
bool hasCamera() {
// Check if camera API is available
return Platform.isAndroid || Platform.isIOS;
}
}
// Policy class
class Policy {
bool shouldShowCameraFeature() {
// Business logic - maybe disabled by store policy
return hasCamera() && !Platform.isIOS;
}
}
Benefits:
For detailed examples, see adaptive-capabilities.md and capability_policy_example.dart.
Switch between bottom navigation (small screens) and navigation rail (large screens):
Widget build(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
return width >= 600
? _buildNavigationRailLayout()
: _buildBottomNavLayout();
}
Complete example: responsive_navigation.dart
Use GridView.extent with responsive maximum width:
LayoutBuilder(
builder: (context, constraints) {
return GridView.extent(
maxCrossAxisExtent: constraints.maxWidth < 600 ? 150 : 200,
// ...
);
},
)
This skill currently has no executable scripts. All guidance is in reference documentation.
This skill includes complete Dart example files demonstrating:
These assets can be copied directly into your Flutter project or adapted to your needs.
documentation
Create organized, visual study notes with folder structures, diagrams, and example-based learning from source materials (PDFs, lecture notes, documentation). Use when creating structured learning materials, exam preparation notes, or educational documentation. Triggers - organize study notes, create visual learning materials, generate notes with diagrams, exam prep notes, example-based learning.
development
Create and present web-based slides for developers using Markdown, Vue components, code highlighting, animations, and interactive features. Use when building technical presentations, conference talks, or teaching materials.
development
Add smooth slide transitions in Slidev. Use this skill for fade, slide, and custom transitions between slides.
development
Use and customize Slidev themes. Use this skill to apply themes, configure theme options, and create custom themes.