Skip to content

[DRAFT] Add convert-dot-shorthand skill and apply to examples#13181

Open
lamek wants to merge 1 commit intomainfrom
add-convert-dot-shorthand-skill-and-examples
Open

[DRAFT] Add convert-dot-shorthand skill and apply to examples#13181
lamek wants to merge 1 commit intomainfrom
add-convert-dot-shorthand-skill-and-examples

Conversation

@lamek
Copy link
Contributor

@lamek lamek commented Mar 14, 2026

This PR introduces a new convert-dot-shorthand skill to automate Dart 3.10 shorthand conversions. It also applies the script to 5 example directories (data-and-backend, get-started, googleapis, state_mgmt, visual_debugging) and consolidates the resulting heuristic rejection reports in temp_shorthand_skill_test_runs/.

@lamek lamek requested review from a team and sfshaza2 as code owners March 14, 2026 01:20
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new convert-dot-shorthand skill, which is a great initiative for modernizing Dart code. The approach of using an aggressive script followed by a review is well-documented. My feedback focuses on refining the skill's documentation (SKILL.md) and the conversion script (apply_all.sh) based on the valuable findings from the test runs you've included. The main suggestions are to correct the documentation regarding Colors.* conversions, which are incorrectly classified as 'good', and to remove this faulty conversion from the script to improve its efficiency.


find "$TARGET_DIR" -type f -name "*.dart" -print0 | while IFS= read -r -d '' file; do
# Colors.black26 -> .black26
sed -i -E 's/Colors\.([a-zA-Z0-9_]+)/\.\1/g' "$file"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The rejection reports show that converting Colors.* to .* consistently leads to compilation errors. This is because the dot shorthand feature requires the static members to be on the contextual type (e.g., Color), but the color constants are on the Colors class.

To make this script more efficient and save the agent from having to revert these changes every time, this conversion rule should be removed. The script should not knowingly introduce errors.

Comment on lines +42 to +48
**Known "Good" Shorthands (Usually Keep):**
* `Colors.*` -> `.*` (It's almost always obvious a color is a color).
* `EdgeInsets.all` / `EdgeInsets.symmetric` -> `.all` / `.symmetric` (Context is extremely strong inside a `padding` or `margin` property).
* `Alignment.*` -> `.*` (Very clear inside an `alignment` property).

**Known "Bad" Shorthands (Always Revert):**
* *Please document rules here as we discover them during manual evaluation.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'Readability Heuristics' section has some inaccuracies based on the findings in the rejection reports. Specifically, Colors.* conversions are listed as 'Good' but they cause compilation errors. Also, the reports identify that FontWeight shorthands for numeric weights are detrimental to readability, which would be a great addition to the 'Bad' shorthands list.

I suggest updating this section to reflect these learnings. This will make the skill documentation more accurate and useful.

Suggested change
**Known "Good" Shorthands (Usually Keep):**
* `Colors.*` -> `.*` (It's almost always obvious a color is a color).
* `EdgeInsets.all` / `EdgeInsets.symmetric` -> `.all` / `.symmetric` (Context is extremely strong inside a `padding` or `margin` property).
* `Alignment.*` -> `.*` (Very clear inside an `alignment` property).
**Known "Bad" Shorthands (Always Revert):**
* *Please document rules here as we discover them during manual evaluation.*
**Known "Good" Shorthands (Usually Keep):**
* `EdgeInsets.all` / `EdgeInsets.symmetric` -> `.all` / `.symmetric` (Context is extremely strong inside a `padding` or `margin` property).
* `Alignment.*` -> `.*` (Very clear inside an `alignment` property).
**Known "Bad" Shorthands (Always Revert):**
* `Colors.*` -> `.*`: This conversion is incorrect because the `Color` class (the typical contextual type) does not have the same static members as the `Colors` class. This will cause `dot_shorthand_undefined_member` compiler errors.
* `FontWeight.w*` -> `.*`: Numeric font weights like `.w600` lose their meaning without the `FontWeight` class name prefix, harming readability.

@flutter-website-bot
Copy link
Collaborator

Visit the preview URL for this PR (updated for commit a160aa8):

https://flutter-docs-prod--pr13181-add-convert-dot-shorthand-s-sm578s2v.web.app

@lamek lamek changed the title Add convert-dot-shorthand skill and apply to examples [DRAFT] Add convert-dot-shorthand skill and apply to examples Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants