Custom Theme in Flutter

Updated 28 April 2023

Save

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.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • James
    • Debabrata Roy (Moderator)
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home