PlugWiki

dart-use-primary-constructors Skill: Dart Constructors

Helps Claude write and migrate Dart classes to primary constructors and the shorter constructor syntax.

Installs
15K
on skills.sh
Stars
3.1K
on GitHub
Updated
Nov 2026
last repo commit

dart-use-primary-constructors makes Claude write and refactor Dart code with primary constructors, where fields and constructor are declared in the class header. It also covers the empty-body semicolon, the in-body this : initializer list and the short new and factory forms.

The SKILL.md says primary constructors are on by default in Dart 3.13 and above, experimental in 3.12 behind a flag, and unsupported in 3.11 and earlier. Check your Dart version first. It bundles no scripts.

Good for

  • Dart and Flutter developers on a Dart version with primary constructors
  • Teams refactoring verbose model classes
  • Anyone debugging primary constructor errors

Install dart-use-primary-constructors

Claude Code

  1. 1

    Copy this prompt.

    Install the dart-use-primary-constructors skill in Claude Code. Run this command:
    
    npx skills add https://github.com/flutter/agent-plugins --skill dart-use-primary-constructors
    
    Then check that it loaded and tell me how to use it.
  2. 2

    Paste it into Claude Code. It shows the change and asks before running it.

Requires Node.js.

From its listing on skills.sh. Source.

What's in the skill

When it loads

Help users write syntactically and semantically correct primary constructors in Dart, and migrate/use the new constructor syntax, empty-body semicolon syntax, in-body initializer list syntax, and abbreviated concise constructor syntax.

Sections in SKILL.md

  1. Dart Version Requirements
  2. 1. Overview
  3. Key Benefits
  4. 2. Syntax Reference
  5. 2.1 Basic Class Header Syntax
  6. 2.2 Declaring, Initializing, and Plain Parameters
  7. 2.3 Constant Primary Constructors
  8. 2.4 Extension Types
  9. 2.5 Empty Body Semicolon Shorthand (;)
  10. 2.6 The In-Body Part of a Primary Constructor (this ...)
  11. 2.7 Abbreviated Concise Constructor Syntax
  12. 3. Semantics & Scoping Rules
  13. 3.1 Primary Initializer Scope
  14. 3.2 Late Instance Variables Restriction
  15. 3.3 Shadowing
  16. 3.4 Generative Constructor Restrictions

Key facts

Installs on skills.sh
15,042
Repo stars
3,136
License
BSD-3-Clause
Last repo commit
2026-11-01
Files in the skill folder
1 file including SKILL.md

What it includes

  • Which Dart versions support the feature

    In 3.12, enable the primary-constructors experiment with a flag or in analysis_options.yaml.

    Version requirements

  • Class header syntax, parameter kinds, const, extension types

    Explains declaring, initializing and plain parameters, const primary constructors, and that extension types must use primary constructors.

    Syntax reference

  • Replace {} with ; on classes, mixins and extension types

    A short form for classes with no body.

    Empty body semicolon

  • Use this : for asserts and initializers

    Initializer lists and constructor bodies go in the class body under this.

    In-body part

  • Write new() and factory() without the class name

    A table pairs each traditional form with its short form.

    Abbreviated constructors

  • Primary initializer scope, late fields, shadowing, restrictions

    Late fields cannot use constructor parameters, and other generative constructors must redirect to the primary one.

    Semantics and scoping

  • Errors and lints with causes and fixes

    Suggests running dart fix for quick-fixable problems.

    Runs code · Diagnostics & troubleshooting

  • Step-by-step move to a primary constructor

    Move fields into the header, then move initializers and asserts into a this block.

    Workflow 5.1: Migrate a class

  • Apply the abbreviated syntax

    Rewrites in-body constructors with new and factory.

    Workflow 5.2: Concise in-body constructors

From the official docs

Questions

What does the dart-use-primary-constructors skill do?

It guides Claude to write correct primary constructor code in Dart and to migrate existing classes, including the semicolon shorthand, in-body initializers and the abbreviated constructor forms.

Which Dart version do I need?

Dart 3.13 or newer has primary constructors on by default. In 3.12 you must enable the primary-constructors experiment, and 3.11 and earlier do not support it.

How do I turn on the experiment in Dart 3.12?

Use the --enable-experiment=primary-constructors flag, or list primary-constructors under analyzer enable-experiment in analysis_options.yaml.

How do I install it?

Use the install box above. The skill is a single SKILL.md in the flutter/agent-plugins repo, which the README says is maintained by the Flutter team.

Does the Flutter plugin add anything else?

The repo's Claude plugin manifest (dart-flutter) also lists a Dart MCP server that runs dart mcp-server. The skills install on this page does not add it.

Is it safe to install?

It bundles no scripts, only one SKILL.md. Claude edits your Dart code when you ask for a migration, so review the diff and run your tests.

Information

updated Nov 2, 2026

Folder
skills/dart-use-primary-constructors

flutter/agent-pluginsskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 3
  1. dart-use-primary-constructors SKILL.md · github.com
  2. flutter/agent-plugins README · github.com
  3. plugin.json · github.com

Updated Nov 2, 2026.