duplicate_field_name
The field name '{0}' is already used in this record.
Description
#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
:
dart
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:
dart
void f((int a, {int a}) r) {}
Common fixes
#Rename one or both of the fields:
dart
var r = (a: 1, b: 2);
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。