Check Mobile App
Read now
Start a Project

Dark Mode in Flutter

Save

Now a days, dark mode in apps have become very popular. Mostly all major apps give choice to users to switch to dark mode. Now let’s see how we can add this feature to our Flutter apps.

Flutter was build with theming, so dealing with OS level dark mode is pretty simple.

If you check the MaterialApp widget you will see we have the theme and darkTheme parameter where we can provide the dark ThemeData in darkTheme and light ThemeData in theme if we want our app to change the theme according to the system preferences.

So here as mentioned in the widget we can set theme and darkTheme.

Below an example of main.dart representing the complete implementation:

Here, I have create a toggle button to switch theme mode using ValueNotifier.

Thanks for reading this article ❤

If I got something wrong 🙈, let me know in the comments. I would love to improve.

. . .

Leave a Comment

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


Be the first to comment.

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