-
-
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
ThemeData implementation #37
Comments
Another example enum style = { elevatedButton, text, etc.. }
TxtStyle.themeData.create(style.elevatedButton)
..elevation(10)
etc...
Widget build(BuildContext context) {
...
Txt(
'some text',
style: TxtStyle.themeData.use(style.elevatedButton)
)
...
}
There might be some more elegant solutions by using the new Dart 2.6 features: https://www.youtube.com/watch?v=GkEuRVkeLpw |
Can you elaborate on what is the current alternative to doing this? I think you should expose the problem first instead of the solution. Then we can really see what can be improved. |
i liked this, with this i not need to create a global widget with an Style. i just need create a global styles |
The idea is to better integrate the way flutter want you to define global style and to for example toggle dark mode. Essentially it would work kinda like how ThemeData works now. On the other hand, maybe it is just as good to do it the way it is now. |
I think it would be cool if you could set styles to light and dark theme on any division class and to multiple keys at once like: // ThemeStyle.of(Brightness brightness).create(Map<String, CoreStyle> themeStyle)
ThemeStyle.of(Brightness.light).create({
'button': TxtStyle()..borderRadius(all: 10)..elevation(10)..textColor(Colors.blue),
'card': ParentStyle()..background.color(Colors.white),
});
ThemeStyle.of(Brightness.dark).create({
'button': TxtStyle()..borderRadius(all: 10)..elevation(10)..textColor(Colors.lightBlue),
'card': ParentStyle()..background.color(Colors.black),
}); Also it could be useful to have a global style to all brightness, as a way to doesn't have to repeat // ThemeStyle.createGlobalStyling(Map<string, CoreStyle> themeStyle)
ThemeStyle.createGlobalStyling({
'button': TxtStyle()..borderRadius(all: 10)..elevation(10)
});
// ThemeStyle.getGlobal(String key)
ThemeStyle.of(Brightness.light).create({
'button': ThemeStyle.getGlobal('button')..textColor(Colors.blue),
'card': ParentStyle()..background.color(Colors.white),
});
ThemeStyle.of(Brightness.dark).create({
'button': ThemeStyle.getGlobal('button')..textColor(Colors.lightBlue),
'card': ParentStyle()..background.color(Colors.black),
}); |
About using enum I've been discussing for months with a coworker, because he wants to use enum to get autocomplete but I want to use String for simplicity. I think the best solution is Swift's that let you use Probably that's the kind of elegant solution you could achieve with Dart 2.6's extensions as seen in the video that you mentioned. But I don't know how to implement it because I'm not using Dart 2.6. |
Was thinking about ways to implement
ThemeData
intoDivision
.Something like this. And maybe it could respond to theme data set globaly, like
brightness: Brightness.dark
in some way.useGlobalTheme
for default background color etc.What do you think? I need feedback to further develop the idea or potentialy discard it. Thanks!
The text was updated successfully, but these errors were encountered: