The "interface segregation" principle (the I in SOLID) tells us to keep the API's of our classes as small as necessary. Following this principle I would think you would want to make any properties on a Widget private if they don't need to be accessed outside the widget.
In Flutter you can't define a named property in a constructor with _
, so the following is not possible:
// throws: Named parameters can't start with an underscore.
String _somePrivateProperty;
Foo({required this._somePrivateProperty})
You can get around this my making the property positional, OR, you can use constructor lists, as follows:
String _somePrivateProperty;
Foo({required String somePrivateProperty}) : _somePrivateProperty = somePrivateProperty;
Here is my question: I rarely see Flutter example code making properties passed in via a constructor private. Why? Is there something about how Dart works that makes this redundant? If not, am I correct to follow SOLID principles and use constructor lists to init private properties via the constructor?