Dart Analyze logoDart Analyze/
DRT-W1311

Duplicate named arguments in method invocationDRT-W1311

Major severityMajor
Bug Risk categoryBug Risk

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}) {}
}