根据开发文档,Dart语言没有public、protected、和private这些关键字。如果一个标识符以下划线(_)开头,它就是该库私有的。但是我在Flutter框架中找到了很多@protected关键字。那么@protected是什么意思呢?
abstract class InheritedWidget extends ProxyWidget {
const InheritedWidget({ Key key, Widget child })
: super(key: key, child: child);
@override
InheritedElement createElement() => InheritedElement(this);
@protected
bool updateShouldNotify(covariant InheritedWidget oldWidget);
}
@protected
是一个注解(而不是语言关键字),由package:meta
提供,并被dartanalyzer
使用。 - jamesdlin