duplicate_named_argument
The argument for the named parameter '{0}' was already specified.
Description
#The analyzer produces this diagnostic when an invocation has two or more named arguments that have the same name.
Example
#The following code produces this diagnostic because there are two arguments with the name a
:
void f(C c) {
c.m(a: 0, a: 1);
}
class C {
void m({int? a, int? b}) {}
}
Common fixes
#If one of the arguments should have a different name, then change the name:
void f(C c) {
c.m(a: 0, b: 1);
}
class C {
void m({int? a, int? b}) {}
}
If one of the arguments is wrong, then remove it:
void f(C c) {
c.m(a: 1);
}
class C {
void m({int? a, int? b}) {}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.