在"Flutter "中,我们通常会遇到这样的情况:
class MyStatefulWidget extends StatefulWidget {
@override
_MyState createState() => _MyState();
}
class _MyState extends State<MyStatefulWidget> {
void doSomething() => print('hi');
@override
Widget build(BuildContext context) {
return Container();
}
}
因此,_MyState
用_
声明,这使它成为库私有.
So how come the Flutter render engine can use 100 if it's sopposed to be private?
这很有趣,因为我可以从其他文件中访问doSomething()
个,但如果我将其设置为_doSomething()
,我将无法再访问它...那么,为什么我可以从私有类访问公共方法,但不能从私有类访问私有方法呢?