Skip to content
flutter avatar

Dart Use Primary Constructors

Concise Dart primary constructor reference covering declaring, initializing, and concise constructor syntax with scoping rules.

CCM score
64 of 100
skills.sh installs
17.8K
GitHub stars
3.2K
last updated
Nov 28, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers primary constructor syntax for classes, extension types, enums, and const variants across Dart 3.12 and 3.13
  • Explains declaring, initializing, and plain parameters, plus the this : in-body initializer list and this {...} bodies
  • Documents Primary Initializer Scope, late field restrictions, parameter shadowing, and generative constructor redirection rules
  • Includes an abbreviated new and factory constructor table and a diagnostics table for common errors and lints

Install

$ npx -y skills add flutter/agent-plugins --skill dart-use-primary-constructors -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Dart Primary Constructors & New Constructor Syntax Skill

Use this skill when helping users write, refactor, or debug code using Dart's Primary Constructors feature.

Dart Version Requirements

  • Dart 3.13 and above: Primary constructors are enabled by default.
  • Dart 3.12: The feature is available but experimental. Users must explicitly enable the experiment flag primary-constructors via --enable-experiment=primary-constructors or in analysis_options.yaml:
analyzer:
  enable-experiment:
    - primary-constructors
  • Dart 3.11 and earlier: Primary constructors are not supported.

1. Overview

Primary Constructors allow developers to declare a non-redirecting generative constructor as well as a set of instance variables directly in the class header. This significantly reduces boilerplate and improves code readability.

Details

Repository
github.com/flutter/agent-plugins
Category
.NET & C#
First seen
Nov 28, 2026

Questions

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

It helps the agent write, refactor and debug Dart code that uses primary constructors, including the empty-body semicolon syntax, in-body initializer lists and the abbreviated concise constructor syntax. It also covers the scoping rules and common compile errors for this syntax.

Which Dart version do I need to use primary constructors?

Primary constructors are enabled by default from Dart 3.13. On Dart 3.12 the feature is experimental and must be turned on with the primary-constructors experiment flag, while Dart 3.11 and earlier do not support them.

How do I install the dart-use-primary-constructors skill?

Run npx -y skills add flutter/agent-plugins --skill dart-use-primary-constructors -y in your project. The skill then lets the agent write Dart primary constructor declarations and migrate older constructor code to the new syntax.

Where does dart-use-primary-constructors rank in its category?

It sits in the .NET & C# category on Claude Marketplaces and ranks in the top 3 of that category page. Its listing is for Dart code, so it sits alongside .NET and C# skills such as dotnet-best-practices and nuget-manager rather than replacing them.

More from flutter/agent-plugins

All 13

Similar to Dart Use Primary Constructors

More .NET & C#