You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if we could annotate a normal property with a @private or @public annotation to declare its visibility.
This way, we wouldn't have to struggle with the, in my opinion, impractical underscore convention for visibility. While it’s a clever approach, it’s not very practical.
Example: Current Dart Visibility Convention
In Dart, you use an underscore _ to mark a property as private within the library:
With annotations, changing visibility would be cleaner and would not require renaming properties. For instance, switching privateProperty to public would be as simple as changing the annotation:
@publicString privateProperty ="I am now public";
This approach could make visibility declarations more robust and readable, reducing potential naming conflicts and confusion. It would also integrate better with modern language features like metadata or decorators.
If Dart supported @private and @public annotations for visibility, a couple of issues with the current implementation would completely disappear.
The text was updated successfully, but these errors were encountered:
It would be nice if we could annotate a normal property with a
@private
or@public
annotation to declare its visibility.This way, we wouldn't have to struggle with the, in my opinion, impractical underscore convention for visibility. While it’s a clever approach, it’s not very practical.
Example: Current Dart Visibility Convention
In Dart, you use an underscore
_
to mark a property as private within the library:However, this convention relies on naming rather than explicit annotations, which can be error-prone or less readable.
Proposal: Use Annotations for Visibility
Imagine if Dart allowed visibility annotations, making code more explicit and standardized:
With annotations, changing visibility would be cleaner and would not require renaming properties. For instance, switching
privateProperty
to public would be as simple as changing the annotation:This approach could make visibility declarations more robust and readable, reducing potential naming conflicts and confusion. It would also integrate better with modern language features like metadata or decorators.
If Dart supported
@private
and@public
annotations for visibility, a couple of issues with the current implementation would completely disappear.The text was updated successfully, but these errors were encountered: