Simplifying Constructor Signatures with unnecessary_type_name_in_constructor
Why repeating the type name in primary constructor declarations is redundant in Dart 3.13 and how to write idiomatic class headers.
Published on • October 24, 2026
AI Assistant

Dart 3.13 primary constructors attach creation signatures directly to class headers. Because the constructor signature is declared immediately following the class identifier, re-stating the class type name inside named sub-constructor headers or redundant type annotations creates unnecessary repetition.
The unnecessary_type_name_in_constructor lint rule ensures constructor declarations remain concise and readable.
Bad Practice vs Good Practice
Non-Idiomatic (Triggers LINT)
Redundantly specifying constructor names or redundant field types where this. parameters already infer field type bindings:
// LINT: Redundant type name repeating inside primary constructor declaration
class UserData.UserData(this.id, String this.name) {
final String id;
final String name;
}
Idiomatic Dart 3.13
In Dart 3.13, this.name automatically inherits the exact type of the field final String name. Explicitly writing String this.name or repeating the class name in the primary signature is redundant:
// Clean, idiomatic Dart 3.13 signature
class UserData(this.id, this.name) {
final String id;
final String name;
}
For named primary constructors, specify only the named suffix (.anonymous or .fromMap):
// Idiomatic named primary constructor
class UserData.anonymous(this.id) {
final String id;
final String name = 'Anonymous';
}
Configuring Analysis Options
Enable the lint rule in your analysis_options.yaml:
linter:
rules:
- unnecessary_type_name_in_constructor
Run dart fix --apply to automatically strip redundant constructor type names across your application code.
Conclusion
Removing redundant constructor type names improves code readability and ensures consistent class design across your Dart and Flutter applications.