Check Mobile App
Read now
Start a Project

Custom Theme in Flutter

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.
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.

. . .

Leave a Comment

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


2 comments

  • James
    Hey If you are able to describe how to call theme.of a little clearer, and identigy the difference between the two images, I.E press this button go to dark mode
    • Debabrata Roy (Moderator)
      In my code, dark and light themes are managed according to the device and I didn’t use any button to active dark mode.
      MaterialApp(title: ‘Flutter Demo’,
      theme: AppTheme.lightTheme,
      darkTheme: AppTheme.darkTheme,)

      Thanks

  • css.php

    When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

    Michael Urresta

    Michael Urresta

    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

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

      Back to Home