Dot Shorthand
/act-dart-migrate-dot-shorthand migrates eligible Dart code to dot shorthand syntax.
Use it when a package is ready for Dart 3.10+ syntax and you want ACT to remove repeated type prefixes where Dart can infer the target type from context.
/act-dart-migrate-dot-shorthandThe skill runs against the current codebase and scans non-generated Dart files for safe dot shorthand opportunities.
Before You Run It
Section titled “Before You Run It”The skill expects the package SDK constraint to allow Dart 3.10 or newer.
The published skill checks for this shape in pubspec.yaml:
environment: sdk: ^3.10.0If the SDK constraint is lower, the skill aborts and asks you to update pubspec.yaml first.
Before migration, make sure:
- your worktree is on a branch or worktree where the diff can be reviewed or reverted
- the package SDK constraint allows Dart 3.10+
- generated files are not edited by hand
- the project can be analyzed after the migration
What It Migrates
Section titled “What It Migrates”Dot shorthand lets Dart omit a repeated type name when the surrounding code already provides the expected type.
The skill can migrate:
- enum values, such as
MainAxisSize.minto.min - named constructors, such as
BorderRadius.circular(8)to.circular(8) - unnamed constructors, such as
ScrollController()to.new()when the context type is explicit - static methods and fields, such as
int.parse('8080')to.parse('8080') - const named constructors, such as
const EdgeInsets.all(8)toconst .all(8)when the context type is clear
It is especially useful in Flutter widget trees where enum values and named constructors often repeat types already implied by named parameters.
Dot shorthand migration has a single mode.
The skill applies supported transformations, runs analysis, fixes analyzer issues caused by the migration, and reports skipped cases.
Example
Section titled “Example”Before:
final content = Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text( 'Save', textAlign: TextAlign.center, ),);After:
final content = Padding( padding: const .symmetric(horizontal: 16), child: Text( 'Save', textAlign: .center, ),);The call-site behavior stays the same. Only the repeated type prefixes are removed where the surrounding context identifies the target type.
What It Skips
Section titled “What It Skips”The skill skips cases where dot shorthand would be invalid, unclear, or less idiomatic.
It skips:
- generated files such as
*.g.dartand*.freezed.dart - expressions without a clear context type
- static members that belong to a related utility class rather than the inferred type
Icons.*values, becauseIcons.infois not a static member onIconData- unnamed constructors in
constexpressions where the explicit type is clearer or required - variable declarations where using
final,var, orconstwith the explicit constructor is more idiomatic than adding an explicit left-hand type just to use.new()
Skipped changes are reported with reasons instead of being guessed at.
Verification and Report
Section titled “Verification and Report”After applying a migration pass, the skill runs analysis:
flutter analyzeThe final report includes:
- total migrated instances
- changes grouped by type, such as enum values, named constructors, or static members
- skipped patterns with reasons
- analyzer results
- a summary of whether the migrated code compiles cleanly
- Review enum and named-constructor changes first; they are usually the clearest wins.
- Do not force
.new()by adding explicit variable types. Preferfinalwith an explicit constructor when there is no useful context type. - Keep full prefixes when they improve clarity or avoid ambiguity.
- If analysis fails after migration, fix migration-caused issues before making unrelated cleanup changes.
References
Section titled “References”- Dart dot shorthands: official language feature guide
- Dart constructors: constructor syntax and constructor kinds
- Dart enums: enum values and enhanced enum behavior
- Dart language versioning: package language-version behavior