unused_field
The value of the field '{0}' isn't used.
Description
#The analyzer produces this diagnostic when a private field is declared but never read, even if it's written in one or more places.
Example
#The following code produces this diagnostic because the field
_originalValue
isn't read anywhere in the library:
dart
class C {
final String _originalValue;
final String _currentValue;
C(this._originalValue) : _currentValue = _originalValue;
String get value => _currentValue;
}
It might appear that the field _originalValue
is being read in the
initializer (_currentValue = _originalValue
), but that is actually a
reference to the parameter of the same name, not a reference to the field.
Common fixes
#If the field isn't needed, then remove it.
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。