-
Notifications
You must be signed in to change notification settings - Fork 8
docs: adapt selected Dart and Flutter skill guidance #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0dcc3d5
docs: add widget test skill
michalurbanek 54eaefa
docs: add layout debug skill
michalurbanek 575736a
docs: improve upgrade conflict workflow
michalurbanek 776bc4e
docs: add dart pattern guidance
michalurbanek db65f14
docs: add error signatures, lockfile tactics, and test setup note to …
michalurbanek e2ecc74
docs: address widget test setup review
michalurbanek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| description: Diagnose and fix Flutter layout, overflow, and responsive UI issues. | ||
| argument-hint: [screen, widget, or layout issue] | ||
| --- | ||
|
|
||
| Use the `layout-debug` skill to fix Flutter layout or responsive rendering issues. | ||
|
|
||
| $ARGUMENTS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| description: Add or update Flutter widget tests using this template's test harness patterns. | ||
| argument-hint: [widget, screen, or behavior to cover] | ||
| --- | ||
|
|
||
| Use the `widget-test` skill to add or update focused Flutter widget tests. | ||
|
|
||
| $ARGUMENTS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../ai/skills/layout-debug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../ai/skills/widget-test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| name: layout-debug | ||
| description: > | ||
| Diagnose and fix Flutter layout, overflow, unbounded constraint, scroll, and responsive | ||
| rendering issues in this repository while preserving the template's existing feature, | ||
| theme, localization, and shared widget patterns. Use when UI overflows, text clips, | ||
| widgets disappear, layouts fail on mobile/tablet/desktop, or a feature needs responsive | ||
| behavior. | ||
| allowed-tools: Bash, Read, Grep, Glob, Edit, Write | ||
| model: claude-sonnet-4-6 | ||
| --- | ||
|
|
||
| # Flutter Template Layout Debug | ||
|
|
||
| Use this skill for UI fixes and responsive layout work in this Flutter template. | ||
|
|
||
| ## Read First | ||
| - `AGENTS.md` | ||
| - `docs/PROJECT_OVERVIEW.md` | ||
| - `docs/PROJECT_GUIDELINES.md` | ||
| - The affected `*_page.dart` and `*_page_content.dart` | ||
| - Shared widgets in `lib/common/component/` or `lib/common/composition/` used by the screen | ||
|
|
||
| ## Diagnosis Checklist | ||
| 1. Reproduce or identify the failing viewport, text scale, platform, and state. | ||
| 2. Inspect the nearest `Row`, `Column`, `Stack`, `ListView`, `SingleChildScrollView`, | ||
| `Expanded`, `Flexible`, and fixed-size widget. | ||
| 3. Find whether the problem is: | ||
| - missing constraints | ||
| - conflicting constraints | ||
| - unbounded scrollable content | ||
| - fixed dimensions where content is dynamic | ||
| - text that cannot wrap or scale within its parent | ||
| - a `Stack` or overlay that visually collides with later content | ||
| 4. Fix the closest layout cause instead of papering over the symptom with arbitrary sizes. | ||
|
|
||
| ## Responsive Guidance | ||
| - Prefer `LayoutBuilder` when a widget must adapt to the actual space its parent gives it. | ||
| - Prefer `MediaQuery.sizeOf(context)` only when the whole screen size matters. | ||
| - Use constrained widths for readable desktop/tablet content, but keep page sections unframed | ||
| unless an existing shared composition already frames that content. | ||
| - Use breakpoints only when the UI meaningfully changes. Avoid sprinkling one-off magic numbers | ||
| through child widgets. | ||
| - Keep page widgets thin; place responsive branching in `*_page_content.dart` or a small local | ||
| helper widget. | ||
|
|
||
| ## Constraint Patterns | ||
| - In a `Row`, wrap long text or flexible content with `Expanded` or `Flexible`. | ||
| - In a `Column`, avoid placing unconstrained scrollables directly inside another unbounded parent. | ||
| - Give grids and fixed-format controls stable dimensions with `aspectRatio`, `SliverGridDelegate`, | ||
| `ConstrainedBox`, or `SizedBox` when dynamic content would otherwise shift layout. | ||
| - Use `SingleChildScrollView` for small form-like pages that can overflow vertically. | ||
| - Use `CustomScrollView` or slivers for larger composed screens with independently sized sections. | ||
| - Use `SafeArea` or existing system-bar helpers when content collides with system UI. | ||
|
|
||
| ## Text And Accessibility | ||
| - Let user-facing strings wrap unless truncation is clearly intended. | ||
| - Use `maxLines` and `overflow` only when the design has a real truncation rule. | ||
| - Verify button labels, tab labels, and card text at narrow widths. | ||
| - Do not solve text overflow by scaling font size with viewport width. | ||
|
|
||
| ## Workflow | ||
| 1. Read the affected widgets and shared components. | ||
| 2. Identify the smallest widget that owns the broken constraints. | ||
| 3. Patch the layout using existing theme/context extensions and shared widgets. | ||
| 4. Add or update a widget test when the issue can be captured deterministically. | ||
| 5. Run a narrow test when available: | ||
| ```bash | ||
| fvm flutter test test/path/to/file_test.dart | ||
| ``` | ||
| 6. Run `fvm flutter analyze` when the fix touches source code. | ||
|
|
||
| ## Completion Criteria | ||
| - No overflow or unbounded-constraint failure remains for the reported state. | ||
| - The fix works for narrow mobile and wider tablet/desktop constraints when the screen supports | ||
| those platforms. | ||
| - Text remains readable, wraps or truncates intentionally, and does not overlap neighboring UI. | ||
| - The solution follows existing feature and shared-widget boundaries. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| name: widget-test | ||
| description: > | ||
| Add or update Flutter widget tests in this repository using the existing test layout, | ||
| Riverpod provider overrides, generated localization, shared theme setup, and FVM test | ||
| commands. Use when a task asks for widget tests, UI regression coverage, test coverage for | ||
| a screen/component, or when implementation work changes visible Flutter behavior. | ||
| allowed-tools: Bash, Read, Grep, Glob, Edit, Write | ||
| model: claude-sonnet-4-6 | ||
| --- | ||
|
|
||
| # Flutter Template Widget Tests | ||
|
|
||
| Use this skill when adding focused widget coverage for a screen, shared component, or UI state in | ||
| this Flutter template. | ||
|
|
||
| ## Read First | ||
| - `AGENTS.md` | ||
| - `docs/PROJECT_OVERVIEW.md` | ||
| - `docs/PROJECT_GUIDELINES.md` | ||
| - Nearby tests under `test/` | ||
| - The widget, provider, and state files being covered | ||
|
|
||
| ## When To Add Widget Tests | ||
| - A shared widget gets new behavior, styling states, callbacks, or accessibility expectations. | ||
| - A feature screen adds meaningful loading, empty, error, or success states. | ||
| - A bug fix changes what the user sees or can tap. | ||
| - A regression would be cheap to catch with a `pumpWidget` test. | ||
|
|
||
| Do not add broad snapshot-style tests that only restate the widget tree. Prefer behavior and | ||
| contract checks: visible text, enabled/disabled states, callbacks, navigation events, empty/error | ||
| rendering, and provider-driven state transitions. | ||
|
|
||
| ## Test Location | ||
| - Shared UI: `test/common/<widget_name>_test.dart` | ||
| - Feature UI: `test/features/<feature>/<feature>_page_content_test.dart` | ||
| - Provider-heavy feature states may also need focused provider tests; keep them near the feature | ||
| test folder unless the repo already has a stronger local pattern. | ||
|
|
||
| ## Harness Pattern | ||
| Build the smallest wrapper that gives the widget the dependencies it expects: | ||
|
|
||
| ```dart | ||
| Widget buildSubject({ | ||
| List<Override> overrides = const [], | ||
| }) { | ||
| return ProviderScope( | ||
| overrides: overrides, | ||
| child: MaterialApp( | ||
| localizationsDelegates: AppLocalizations.localizationsDelegates, | ||
| supportedLocales: AppLocalizations.supportedLocales, | ||
| theme: AppTheme.getThemeData(brightness: Brightness.light), | ||
| home: const Scaffold( | ||
| body: SubjectWidget(), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| Adapt imports to the current code. If the existing nearby tests use `patrolWidgetTest`, | ||
| `pumpWidgetAndSettle`, or another helper, reuse that style instead of creating a parallel harness. | ||
|
|
||
| ## Riverpod Guidance | ||
| - Wrap provider-dependent widgets in `ProviderScope`. | ||
| - Override IO, auth, storage, and notifier providers rather than hitting real services. | ||
| - Keep overrides explicit in each test group so state does not leak between tests. | ||
| - For one-off event flows, assert the visible side effect when possible. If navigation/snackbars | ||
| are difficult to observe directly, test the notifier event separately and keep the page listener | ||
| thin. | ||
|
|
||
| ## Route And Localization Guidance | ||
| - If the widget uses `context.router`, prefer an AutoRoute-aware harness or test the lower-level | ||
| content widget instead of the route page. | ||
| - If the widget reads `context.locale`, include generated localization delegates. | ||
| - Add localization keys in `assets/localization/app_en.arb` and run `make gen` before relying on | ||
| generated getters. | ||
|
|
||
| ## Workflow | ||
| 1. Read the widget and the closest existing tests. | ||
| 2. Pick the smallest test subject that still covers the behavior. | ||
| 3. Add or update test files under `test/`. | ||
| 4. Use `tester.pumpWidget(...)`, `tester.pump()`, and `tester.pumpAndSettle()` intentionally; | ||
| avoid arbitrary waits. | ||
| 5. Assert user-observable behavior with `find`, callback counters, and provider state. | ||
| 6. Run the narrow test file first: | ||
| ```bash | ||
| fvm flutter test test/path/to/file_test.dart | ||
| ``` | ||
| 7. Run the full test suite when the change touches shared UI or state: | ||
| ```bash | ||
| fvm flutter test | ||
| ``` | ||
|
|
||
| ## Completion Criteria | ||
| - Tests are deterministic and isolated. | ||
| - No real network, Firebase, storage, or platform side effects run during widget tests. | ||
| - Test names describe behavior, not implementation details. | ||
| - `fvm flutter test` or the relevant narrowed test command passes. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.