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
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
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
- Dart Version Requirements
- 1. Overview
- Key Benefits
- 2. Syntax Reference
- 2.1 Basic Class Header Syntax
- 2.2 Declaring, Initializing, and Plain Parameters
- 2.3 Constant Primary Constructors
- 2.4 Extension Types
- 2.5 Empty Body Semicolon Shorthand (;)
- 2.6 The In-Body Part of a Primary Constructor (this ...)
- 2.7 Abbreviated Concise Constructor Syntax
- 3. Semantics & Scoping Rules
- 3.1 Primary Initializer Scope
- 3.2 Late Instance Variables Restriction
- 3.3 Shadowing
- 3.4 Generative Constructor Restrictions
Key facts
- Author
- flutter (repo owner)
- 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 requirementsClass 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 referenceReplace {} with ; on classes, mixins and extension types
A short form for classes with no body.
Empty body semicolonUse this : for asserts and initializers
Initializer lists and constructor bodies go in the class body under this.
In-body partWrite new() and factory() without the class name
A table pairs each traditional form with its short form.
Abbreviated constructorsPrimary initializer scope, late fields, shadowing, restrictions
Late fields cannot use constructor parameters, and other generative constructors must redirect to the primary one.
Semantics and scopingErrors and lints with causes and fixes
Suggests running dart fix for quick-fixable problems.
Runs code ·
Diagnostics & troubleshootingStep-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 classApply 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
- Repository
- flutter/agent-plugins
- Folder
skills/dart-use-primary-constructors
Sources
Docs, issue trackers and discussions this page is built from.
Show all 3Hide
- dart-use-primary-constructors SKILL.md · github.com
- flutter/agent-plugins README · github.com
- plugin.json · github.com