-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Create @private, just like we have @protected #41089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
CC @lrhn |
I'm not sure what problem this will solve. The A The only advantage suggested here is to not need to write I see no positive outcome of adding this annotation. Any use of it is either going to be library private already, in which case the annotation provides very little protection - only against the author of the library who can remove the annotation at will - or it's going to not be private, and then it's fundamentally flawed. (It's an annotation, though, so I can't actually stop anyone from adding it. I just highly recommend not doing so). |
@lrhn Sure I don't like it. It makes code difficult to read. Some code ends up with hundreds of useless You say you do not want people to use I just opened this issue because #33383 was closed. Dart was not a very popular language before Flutter, and I believe it's a missed opportunity not trying to understand why and fix those problems. |
The use I see for the |
Python does this and is one of the most widely used programming languages in the world, so it's not as though this design pattern hinders language adoption. I understand the desire for something with its function explicit so you can understand what it means without being familiar with the language, but I believe it works for the most part if you're familiar with a few of the most popular programming languages. After all, even C uses underscores before identifiers and tokens that the designers want people to use sparingly if at all. Look at the compiler provided |
class LocalStorageDataSource {
LocalStorageDataSource({required FlutterSecureStorage secureStorage}) : _secureStorage = secureStorage;
final FlutterSecureStorage _secureStorage; It could be just: class LocalStorageDataSource {
LocalStorageDataSource({required this.secureStorage});
@private
final FlutterSecureStorage secureStorage; The difference might seem small, but most this code is auto-generated by the IDE (e.g. "add final fields missing parameters") so it makes a big difference on the amount that we type. I use |
We should have a
@private
annotation, since it's unlikely we'll ever have theprivate
keyword (#33383), just like most languages do.It wouldn't really make it private in the
_
sense, but the IDE would warn us if we use it outside of the class. That's what it does with@protected
.That would be very helpful because adding
_
is not very clean-code, and we have a lot of code which remains public for that reason.That's also very easy to implement.
There's no reason for us to have
@protected
and not@private
, since_
is not a good solution, but just a compromise for performance reasons as explained in #33383.The text was updated successfully, but these errors were encountered: