-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
TextStyle extensions? #43
Comments
If you like the idea, I can do a PR for you sometime this week. |
We've created a lib here, if you'd like to include it in yours as a dependency that would be pretty cool :) |
Cool package, however I am not really a big fan of all the shorthands. For example clr instead of color. I am also a little bit concerned about the performance of when copying the style for each textstyle parameter |
Ya I had to basically embrace the shorthand since there were so many conflicts with the underlying API. |
I see. But I would rather prefer textColor instead of clr for example. Anyways I will keep this issue open for now and follow the development |
Ya that's fair, but we would end up with things like textBaseline and textDecoration and textWordSpacing. But ya I think you're right, that works a little better overall... |
I've updated the API with better naming, thanks for the feedback. |
My main concern with this, just like with CustomText
.bold()
.fontSize(24)
.build() where build returns a TextStyle object. StyledText("Text")
.bold()
.fontSize()
.build() // builds into Text object
.padding(all: 10)
// etc |
Oh interesting, that would be better for performance, and also stop the fighting with the property names on TextStyle. I agree, much better :) The downside to this approach is it doesn't lend itself well to pre-declaring. Typically we would have a bunch of shared TextStyles:
But that's probably ok, as long as we can use it inline in the Widget's themselves, I think that's the primary use case. |
Actually it would then be better in the example I gave to use double dot before the method (https://dart-lang.github.io/linter/lints/avoid_returning_this.html) CustomText // example name
..bold()
..fontSize(24)
.bold() |
Just created this, hope it helps https://github.com/sooxt98/textless 😉 |
@sooxt98 Maybe we should be able to merge the package into this? You are using
|
We recently added some extensions directly to TextStyle, and they are really handy:
Now, instead of
TextStyles.body.copyWith(fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, letterSpacing: 1.6)
Can use:
TextStyles.body.bold.italic.letterSpacing(1.6)
I know these are technically not widgests, but I can't think of a better place to house these than this repo :)
The text was updated successfully, but these errors were encountered: