with reference to the Flutter tutorial, I encountered an underscore, _.
I know that in Java, _ is used as a naming convention for a private
It's not just a naming convention. Underscore fields, classes and methods will only be available in the .dart file where they are defined.
It is common practice to make the State implementation of a widget private, so that it can only be instantiated by the corresponding StatefulWidget:
class MyPage extends StatefulWidget {
@override
_MyPageState createState() => _MyPageState();
}
class _MyPageState extends State {
@override
Widget build(BuildContext context) {
return Container();
}
}