[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BV9WM9NBCRGBE50Y7SZ7J9":3,"skill-same:01M7BV9WM9NBCRGBE50Y7SZ7J9":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7BV9WM9NBCRGBE50Y7SZ7J9","flutter-build-responsive-layout",null,"Use `LayoutBuilder`, `MediaQuery`, or `Expanded\u002FFlexible` to create a layout that adapts to different screen sizes. Use when you need the UI to look good on both mobile and tablet\u002Fdesktop form factors.","nguyenhungtran18\u002Fskill-and-tool-tracker","nguyenhungtran18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F297063550?v=4","01M7BV0BFPRRFP84F2ME0FYZ9D","01M7BV0BG83FA5P22NJV0GR0A5",1,"MIT","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fflutter-build-responsive-layout\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: flutter-build-responsive-layout\ndescription: Use `LayoutBuilder`, `MediaQuery`, or `Expanded\u002FFlexible` to create a layout that adapts to different screen sizes. Use when you need the UI to look good on both mobile and tablet\u002Fdesktop form factors.\nmetadata:\n  model: models\u002Fgemini-3.1-pro-preview\n  last_modified: Tue, 21 Apr 2026 20:17:40 GMT\n---\n# Implementing Adaptive Layouts\n\n## Contents\n- [Space Measurement Guidelines](#space-measurement-guidelines)\n- [Widget Sizing and Constraints](#widget-sizing-and-constraints)\n- [Device and Orientation Behaviors](#device-and-orientation-behaviors)\n- [Workflow: Constructing an Adaptive Layout](#workflow-constructing-an-adaptive-layout)\n- [Workflow: Optimizing for Large Screens](#workflow-optimizing-for-large-screens)\n- [Examples](#examples)\n\n## Space Measurement Guidelines\nDetermine the available space accurately to ensure layouts adapt to the app window, not just the physical device.\n\n*   **Use `MediaQuery.sizeOf(context)`** to get the size of the entire app window.\n*   **Use `LayoutBuilder`** to make layout decisions based on the parent widget's allocated space. Evaluate `constraints.maxWidth` to determine the appropriate widget tree to return.\n*   **Do not use `MediaQuery.orientationOf` or `OrientationBuilder`** near the top of the widget tree to switch layouts. Device orientation does not accurately reflect the available app window space.\n*   **Do not check for hardware types** (e.g., \"phone\" vs. \"tablet\"). Flutter apps run in resizable windows, multi-window modes, and picture-in-picture. Base all layout decisions strictly on available window space.\n\n## Widget Sizing and Constraints\nUnderstand and apply Flutter's core layout rule: **Constraints go down. Sizes go up. Parent sets position.**\n\n*   **Distribute Space:** Use `Expanded` and `Flexible` within `Row`, `Column`, or `Flex` widgets.\n    *   Use `Expanded` to force a child to fill all remaining available space (equivalent to `Flexible` with `fit: FlexFit.tight` and a `flex` factor of 1.0).\n    *   Use `Flexible` to allow a child to size itself up to a specific limit while still expanding\u002Fcontracting. Use the `flex` factor to define the ratio of space consumption among siblings.\n*   **Constrain Width:** Prevent widgets from consuming all horizontal space on large screens. Wrap widgets like `GridView` or `ListView` in a `ConstrainedBox` or `Container` and define a `maxWidth` in the `BoxConstraints`.\n*   **Lazy Rendering:** Always use `ListView.builder` or `GridView.builder` when rendering lists with an unknown or large number of items.\n\n## Device and Orientation Behaviors\nEnsure the app behaves correctly across all device form factors and input methods.\n\n*   **Do not lock screen orientation.** Locking orientation causes severe layout issues on foldable devices, often resulting in letterboxing (the app centered with black borders). Android large format tiers require both portrait and landscape support.\n*   **Fallback for Locked Orientation:** If business requirements strictly mandate a locked orientation, use the `Display API` to retrieve physical screen dimensions instead of `MediaQuery`. `MediaQuery` fails to receive the larger window size in compatibility modes.\n*   **Support Multiple Inputs:** Implement support for basic mice, trackpads, and keyboard shortcuts. Ensure touch targets are appropriately sized and keyboard navigation is accessible.\n\n## Workflow: Constructing an Adaptive Layout\n\nFollow this workflow to implement a layout that adapts to the available `BoxConstraints`.\n\n**Task Progress:**\n- [ ] Identify the target widget that requires adaptive behavior.\n- [ ] Wrap the widget tree in a `LayoutBuilder`.\n- [ ] Extract the `constraints.maxWidth` from the builder callback.\n- [ ] Define an adaptive breakpoint (e.g., `largeScreenMinWidth = 600`).\n- [ ] **If `maxWidth > largeScreenMinWidth`:** Return a large-screen layout (e.g., a `Row` placing a navigation sidebar and content area side-by-side).\n- [ ] **If `maxWidth \u003C= largeScreenMinWidth`:** Return a small-screen layout (e.g., a `Column` or standard navigation-style approach).\n- [ ] Run validator -> resize the application window -> review layout transitions -> fix overflow errors.\n\n## Workflow: Optimizing for Large Screens\n\nFollow this workflow to prevent UI elements from stretching unnaturally on large displays.\n\n**Task Progress:**\n- [ ] Identify full-width components (e.g., `ListView`, text blocks, forms).\n- [ ] **If optimizing a list:** Convert `ListView.builder` to `GridView.builder` using `SliverGridDelegateWithMaxCrossAxisExtent` to automatically adjust column counts based on window size.\n- [ ] **If optimizing a form or text block:** Wrap the component in a `ConstrainedBox`.\n- [ ] Apply `BoxConstraints(maxWidth: [optimal_width])` to the `ConstrainedBox`.\n- [ ] Wrap the `ConstrainedBox` in a `Center` widget to keep the constrained content centered on large screens.\n- [ ] Run validator -> test on desktop\u002Ftablet target -> review horizontal stretching -> adjust `maxWidth` or grid extents.\n\n## Examples\n\n### Adaptive Layout using LayoutBuilder\nDemonstrates switching between a mobile and desktop layout based on available width.\n\n```dart\nimport 'package:flutter\u002Fmaterial.dart';\n\nconst double largeScreenMinWidth = 600.0;\n\nclass AdaptiveLayout extends StatelessWidget {\n  const AdaptiveLayout({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return LayoutBuilder(\n      builder: (context, constraints) {\n        if (constraints.maxWidth > largeScreenMinWidth) {\n          return _buildLargeScreenLayout();\n        } else {\n          return _buildSmallScreenLayout();\n        }\n      },\n    );\n  }\n\n  Widget _buildLargeScreenLayout() {\n    return Row(\n      children: [\n        const SizedBox(width: 250, child: Placeholder(color: Colors.blue)),\n        const VerticalDivider(width: 1),\n        Expanded(child: const Placeholder(color: Colors.green)),\n      ],\n    );\n  }\n\n  Widget _buildSmallScreenLayout() {\n    return const Placeholder(color: Colors.green);\n  }\n}\n```\n\n### Constraining Width on Large Screens\nDemonstrates preventing a widget from consuming all horizontal space.\n\n```dart\nimport 'package:flutter\u002Fmaterial.dart';\n\nclass ConstrainedContent extends StatelessWidget {\n  const ConstrainedContent({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      body: Center(\n        child: ConstrainedBox(\n          constraints: const BoxConstraints(\n            maxWidth: 800.0, \u002F\u002F Maximum width for readability\n          ),\n          child: ListView.builder(\n            itemCount: 50,\n            itemBuilder: (context, index) {\n              return ListTile(\n                title: Text('Item $index'),\n              );\n            },\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n","# Implementing Adaptive Layouts\n\n## Contents\n- [Space Measurement Guidelines](#space-measurement-guidelines)\n- [Widget Sizing and Constraints](#widget-sizing-and-constraints)\n- [Device and Orientation Behaviors](#device-and-orientation-behaviors)\n- [Workflow: Constructing an Adaptive Layout](#workflow-constructing-an-adaptive-layout)\n- [Workflow: Optimizing for Large Screens](#workflow-optimizing-for-large-screens)\n- [Examples](#examples)\n\n## Space Measurement Guidelines\nDetermine the available space accurately to ensure layouts adapt to the app window, not just the physical device.\n\n*   **Use `MediaQuery.sizeOf(context)`** to get the size of the entire app window.\n*   **Use `LayoutBuilder`** to make layout decisions based on the parent widget's allocated space. Evaluate `constraints.maxWidth` to determine the appropriate widget tree to return.\n*   **Do not use `MediaQuery.orientationOf` or `OrientationBuilder`** near the top of the widget tree to switch layouts. Device orientation does not accurately reflect the available app window space.\n*   **Do not check for hardware types** (e.g., \"phone\" vs. \"tablet\"). Flutter apps run in resizable windows, multi-window modes, and picture-in-picture. Base all layout decisions strictly on available window space.\n\n## Widget Sizing and Constraints\nUnderstand and apply Flutter's core layout rule: **Constraints go down. Sizes go up. Parent sets position.**\n\n*   **Distribute Space:** Use `Expanded` and `Flexible` within `Row`, `Column`, or `Flex` widgets.\n    *   Use `Expanded` to force a child to fill all remaining available space (equivalent to `Flexible` with `fit: FlexFit.tight` and a `flex` factor of 1.0).\n    *   Use `Flexible` to allow a child to size itself up to a specific limit while still expanding\u002Fcontracting. Use the `flex` factor to define the ratio of space consumption among siblings.\n*   **Constrain Width:** Prevent widgets from consuming all horizontal space on large screens. Wrap widgets like `GridView` or `ListView` in a `ConstrainedBox` or `Container` and define a `maxWidth` in the `BoxConstraints`.\n*   **Lazy Rendering:** Always use `ListView.builder` or `GridView.builder` when rendering lists with an unknown or large number of items.\n\n## Device and Orientation Behaviors\nEnsure the app behaves correctly across all device form factors and input methods.\n\n*   **Do not lock screen orientation.** Locking orientation causes severe layout issues on foldable devices, often resulting in letterboxing (the app centered with black borders). Android large format tiers require both portrait and landscape support.\n*   **Fallback for Locked Orientation:** If business requirements strictly mandate a locked orientation, use the `Display API` to retrieve physical screen dimensions instead of `MediaQuery`. `MediaQuery` fails to receive the larger window size in compatibility modes.\n*   **Support Multiple Inputs:** Implement support for basic mice, trackpads, and keyboard shortcuts. Ensure touch targets are appropriately sized and keyboard navigation is accessible.\n\n## Workflow: Constructing an Adaptive Layout\n\nFollow this workflow to implement a layout that adapts to the available `BoxConstraints`.\n\n**Task Progress:**\n- [ ] Identify the target widget that requires adaptive behavior.\n- [ ] Wrap the widget tree in a `LayoutBuilder`.\n- [ ] Extract the `constraints.maxWidth` from the builder callback.\n- [ ] Define an adaptive breakpoint (e.g., `largeScreenMinWidth = 600`).\n- [ ] **If `maxWidth > largeScreenMinWidth`:** Return a large-screen layout (e.g., a `Row` placing a navigation sidebar and content area side-by-side).\n- [ ] **If `maxWidth \u003C= largeScreenMinWidth`:** Return a small-screen layout (e.g., a `Column` or standard navigation-style approach).\n- [ ] Run validator -> resize the application window -> review layout transitions -> fix overflow errors.\n\n## Workflow: Optimizing for Large Screens\n\nFollow this workflow to prevent UI elements from stretching unnaturally on large displays.\n\n**Task Progress:**\n- [ ] Identify full-width components (e.g., `ListView`, text blocks, forms).\n- [ ] **If optimizing a list:** Convert `ListView.builder` to `GridView.builder` using `SliverGridDelegateWithMaxCrossAxisExtent` to automatically adjust column counts based on window size.\n- [ ] **If optimizing a form or text block:** Wrap the component in a `ConstrainedBox`.\n- [ ] Apply `BoxConstraints(maxWidth: [optimal_width])` to the `ConstrainedBox`.\n- [ ] Wrap the `ConstrainedBox` in a `Center` widget to keep the constrained content centered on large screens.\n- [ ] Run validator -> test on desktop\u002Ftablet target -> review horizontal stretching -> adjust `maxWidth` or grid extents.\n\n## Examples\n\n### Adaptive Layout using LayoutBuilder\nDemonstrates switching between a mobile and desktop layout based on available width.\n\n```dart\nimport 'package:flutter\u002Fmaterial.dart';\n\nconst double largeScreenMinWidth = 600.0;\n\nclass AdaptiveLayout extends StatelessWidget {\n  const AdaptiveLayout({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return LayoutBuilder(\n      builder: (context, constraints) {\n        if (constraints.maxWidth > largeScreenMinWidth) {\n          return _buildLargeScreenLayout();\n        } else {\n          return _buildSmallScreenLayout();\n        }\n      },\n    );\n  }\n\n  Widget _buildLargeScreenLayout() {\n    return Row(\n      children: [\n        const SizedBox(width: 250, child: Placeholder(color: Colors.blue)),\n        const VerticalDivider(width: 1),\n        Expanded(child: const Placeholder(color: Colors.green)),\n      ],\n    );\n  }\n\n  Widget _buildSmallScreenLayout() {\n    return const Placeholder(color: Colors.green);\n  }\n}\n```\n\n### Constraining Width on Large Screens\nDemonstrates preventing a widget from consuming all horizontal space.\n\n```dart\nimport 'package:flutter\u002Fmaterial.dart';\n\nclass ConstrainedContent extends StatelessWidget {\n  const ConstrainedContent({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      body: Center(\n        child: ConstrainedBox(\n          constraints: const BoxConstraints(\n            maxWidth: 800.0, \u002F\u002F Maximum width for readability\n          ),\n          child: ListView.builder(\n            itemCount: 50,\n            itemBuilder: (context, index) {\n              return ListTile(\n                title: Text('Item $index'),\n              );\n            },\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n",{"name":5,"metadata":23,"description":7},{"model":24,"last_modified":25},"models\u002Fgemini-3.1-pro-preview","Tue, 21 Apr 2026 20:17:40 GMT","main","900ea3c9eb045fd5b0317dc1103777ecf3ea4aeb","skills\u002Fflutter-build-responsive-layout",0,"https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker","https:\u002F\u002Fnguyenhungtran18.github.io\u002Fskill-and-tool-tracker\u002F","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18","2026-08-31 18:36:09",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill flutter-build-responsive-layout",{"tool":40,"command":41},"bunx","bunx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill flutter-build-responsive-layout",{"tool":43,"command":44},"pnpm","pnpm dlx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill flutter-build-responsive-layout","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fflutter-build-responsive-layout\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M7BVP4P83TK60JZ4P8RP9VP7","xcode-project-setup","Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fxcode_project_setup\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M7BVP01K4CSJJ8G90FT8S2D5","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M7BVNY22GXD871GYTSH599F1","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-plans\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M7BVNQWF24RNKA8A4KM2HJ3T","workflow-skill-creator","Distills a completed user workflow or interaction into a reusable agent skill. Use when the user asks to turn their workflow, interaction, or multi-step process into a skill, or when they say \"make this a skill\", \"create a skill from what we just did\", \"package this workflow\" or similar. Do not use for creating skills from scratch without an existing workflow (use a generic skill-creator for that).","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow_skill_creator\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M7BVNNY67XPCQAQHY3FBKDGC","verify-and-stop","Prove existing work meets acceptance conditions without expanding scope. Use for validation-only tasks, completion checks, focused gate runs, and last-mile proof.","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fverify-and-stop\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M7BVNKB4Z7SZT85B73ZZ90Y6","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fverification-before-completion\u002FSKILL.md",[],[]]