private_setter
The setter '{0}' is private and can't be accessed outside the library that declares it.
Description
#The analyzer produces this diagnostic when a private setter is used in a library where it isn't visible.
Example
#Given a file a.dart
that contains the following:
dart
class A {
static int _f = 0;
}
The following code produces this diagnostic because it references the
private setter _f
even though the setter isn't visible:
dart
import 'a.dart';
void f() {
A._f = 0;
}
Common fixes
#If you're able to make the setter public, then do so:
dart
class A {
static int f = 0;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。