Sitemap
The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Flutter dynamic themes in 3 lines!

5 min readMay 18, 2020

--

Three lines. Really?

Yep, and as a bonus you’ll get to take home a fully functional theme demo app that’s less than 100 lines of code.

Press enter or click to view image in full size
Photo by Willian Justen de Vasconcellos on Unsplash

The Why of the 3 lines

So why are we doing this?

Like many other Flutter developers I’ve read a lot of articles and tried a few techniques to dynamically change the theme on my app. They all work, but they also have a few drawbacks:

  1. I needed to write a service or controller to manage the theme state, or use a dedicated theme switcher package to get the job done
  2. Those solutions will allow me to choose between light and dark themes or even a rainbow of themes, but they typically don’t allow me to sync the App’s theme to the device as it’s switched between light and dark modes. This isn’t always the case, but see point 1
  3. The growing number of articles available on managing Flutter themes and the fact that you’re reading this tells me that this is a topic where developers are still searching for a better answer. Why? See points 1 and 2.

Let’s look at a solution that will address those issues… In 3 lines.

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Rod Brown
Rod Brown

Written by Rod Brown

Coffee, cake, code… in that order.

Responses (6)