Dart Analyze logoDart Analyze/
DRT-W1307

Duplicate field name in record literal or type annotationDRT-W1307

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when either a record literal or a record type annotation contains a field whose name is the same as a previously declared field in the same literal or type.

Examples

The following code produces this diagnostic because the record literal has two fields named a:

var r = (a: 1, a: 2);

The following code produces this diagnostic because the record type annotation has two fields named a, one a positional field and the other a named field:

void f((int a, {int a}) r) {}

Common fixes

Rename one or both of the fields:

var r = (a: 1, b: 2);