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
:
dart
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:
dart
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:
dart
void f(C c) {
c.m(a: 1);
}
class C {
void m({int? a, int? b}) {}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。