Start a Project

Custom Theme in Flutter

Flutter provides a great feature Theme to control UI. This allows developers to improve this design and also manage different custom themes (like dark). A theme describes the colors and typographic choices of an application. To know more about the theme please check flutter doc.

Read more about Flutter app development services from mobikul.

Before start let discuss some concept in Theme.

ThemeData class defines the configuration of the overall visual Theme for a MaterialApp or a widget subtree within the app.
The static Theme.of method finds the ThemeData value specified for the nearest BuildContext ancestor. This lookup is inexpensive, essentially just single HashMap access.

After defining a Theme, use it within your own widgets. Flutter’s Material widgets also use your Theme to set the background colors and font styles for AppBars, Buttons, Checkboxes, and more.

In this blog, I will implement a custom theme for both dark and light and also use common font for all widgets.
Let’s start.
First, create a Theme class and add color according to what you want in your app.

Now call the Theme element.

I hope this code will help you better to understand Custom Theme in flutter. If you feel any doubt or query please comment below.

Thanks for the read this blog and if you want to visit my other blog click here.

Exit mobile version