【发布时间】:2020-08-31 18:02:48
【问题描述】:
正如开发文档所说,Dart doesn't have the keywords public , protected , and private . If an identifier starts with an underscore (_), it's private to its library. 但我在 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使用。