Move Bidi static methods to instance methods on TextDirection #334
Labels
closed-not-planned
Closed as we don't intend to take action on the reported issue
type-enhancement
A request for a change that isn't a bug
<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="96" height="96"hspace="10"> Issue by seaneagan
Originally opened as dart-lang/sdk#11752
In package:intl, Bidi acts as a namespace for static methods, which is generally an anti-pattern in dart, since dart libraries can act as namespaces for static methods, so a separate "bidi.dart" library maybe. However, most of these methods are duplicated for both TextDirections (RTL and LTR), so it seems like making them polymorphic to TextDirection would make sense. For a basic idea of what this would look like, see:
https://gist.github.com/seaneagan/5957736
Of course they wouldn't make sense for TextDirection.UNKNOWN, but I don't think TextDirection.UNKNOWN is necessary. I think it would make more sense just to reuse
null
for that concept.Another option would be to keep them as static/top-level methods which receive a TextDirection, but that doesn't feel quite as nice.
The text was updated successfully, but these errors were encountered: