-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
The future of styling widgets (new package) #48
Comments
The problem I see with this approach is that you cannot hoist/abstract the styling like you would in CSS. Maybe explore the decorator pattern for it, who knows. |
Yes its not possible to create style like in This could be a way to decouple style final Styled textStyle = Styled.text()
.backgroundColor(Colors.blue)
final Styled iconStyle = Styled.icon()
.iconSize(24)
.alignment(Alignment.center)
final Styled widgetStyle = Styled.widget()
.bordeRadius(all: 10)
Widget build(BuildContext context) {
...
Text('some text').style(textStyle),
Icon(Icons.icon).style(iconStyle),
Container().style(widgetStyle)
...
} |
@ReinBentdal This looks like the way it is supposed to be. It is inviting for any React.js enthusiast. |
@ReinBentdal I would like to help you out in this direction, it looks promising. I don't have much time on my hands but I can help. Just lead the way. |
This is probably the easiest way to decouple style in my opinion final styledWidget = (Widget child) => Styled.widget(child)
.backgroundColor(Colors.blue)
.constraints(width: 100, height: 100)
.borderRadius(all: 10)
.elevation(10)
.alignment(Alignment.center); This makes to coding part much easier as well extension Styled on Widget {
static Widget widget([Widget child]) => ...
} |
I have made a new package called
styled_widget
which uses the new dart extension feature added in dart version 2.6.0. This is just an early concept.GitHub: https://github.com/ReinBentdal/styled_widget
Pub: https://pub.dev/packages/styled_widget (Pub clearly didnt like dart version 2.6.0)
What do you think? Is there a future in styling widgets this way? If you like the concept or dont, let me know! Of course contributions are very welcome.
The text was updated successfully, but these errors were encountered: