Skip to content

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.

Terminal window
/act-dart-migrate-dot-shorthand

The skill runs against the current codebase and scans non-generated Dart files for safe dot shorthand opportunities.

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.0

If 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

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.min to .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) to const .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.

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.

The skill skips cases where dot shorthand would be invalid, unclear, or less idiomatic.

It skips:

  • generated files such as *.g.dart and *.freezed.dart
  • expressions without a clear context type
  • static members that belong to a related utility class rather than the inferred type
  • Icons.* values, because Icons.info is not a static member on IconData
  • unnamed constructors in const expressions where the explicit type is clearer or required
  • variable declarations where using final, var, or const with 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.

After applying a migration pass, the skill runs analysis:

Terminal window
flutter analyze

The 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. Prefer final with 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.