Themes — Part 3 — Flutter

Mathiazhagan Dinesh
1 min readAug 27, 2022

--

In the previous stories, we have learned light/dark themes and how to change the theme dynamically. We can also change the different light themes dynamically. In this story, we are going to learn that.

We already learned about ThemeData and ValueListenableBuilder. Here also we are using the same, except we are having two different ThemeData. Instead of directly configuring the ThemeData in the MaterialApp widget, we can define it separately and using the ValueListenableBuilder, ThemeData can be changed.

In our example, we have created two ThemeData namely blueThemeData() and redThemeData() and configured them with a different colour scheme.

In our previous light/dark theme change example, we have changed the themeMode value. But here, we are changing theme.

As mentioned in the previous stories, there are so many things to learn in Themes. And we made small progress from this story. You can find the full code in the above-mentioned code pen link. Happy coding!

--

--

No responses yet