Dynamic Theme

In current Age, All mobile App have duel theme. Here we introduce change App theme dynamically. Theme change on button click.

You can Download Source Code via Github.

Implement theme

Light theme

static final ThemeData lightTheme = ThemeData(
    primaryColor: UtilsImporter().colorUtils.primarycolor,
    primaryColorLight: Colors.white,
    primaryColorDark: Colors.black,
    brightness: Brightness.light,
    inputDecorationTheme: InputDecorationTheme(
        focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(
                color: UtilsImporter().colorUtils.primarycolor))),
  );

Dark theme

static final ThemeData darkTheme = ThemeData(
    primaryColor: UtilsImporter().colorUtils.primarycolor,
    primaryColorLight: Colors.black,
    primaryColorDark: Colors.white,
    brightness: Brightness.dark,
    inputDecorationTheme: InputDecorationTheme(
        focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(
                color: UtilsImporter().colorUtils.primarycolor))),
  );

Change theme

onTap: () {
                    if (isDarkThemeMode == true) {
                      setState(() {
                        isDarkThemeMode = false;
                      });

                      _changeTheme(context, MyThemeKeys.LIGHT);
                    } else {
                      setState(() {
                        isDarkThemeMode = true;
                      });

                      _changeTheme(context, MyThemeKeys.DARK);
                    }
                  },


 void _changeTheme(BuildContext buildContext, MyThemeKeys key) {
    CustomTheme.instanceOf(buildContext).changeTheme(key);
  }

You can Download Source Code via Github.

19 Replies to “Dynamic Theme”

  1. I got this web site from my friend who informed me
    on the topic of this web page and at the moment this time
    I am visiting this web site and reading very
    informative articles or reviews here.

  2. It’s very trouble-free to find out any matter on web as compared to textbooks, as I found this piece of writing at this web page.

  3. Nice post. I learn something new and challenging on websites I stumbleupon everyday.
    It’s always exciting to read articles from other writers and practice
    something from other web sites.

  4. Wow that was odd. I just wrote an extremely long comment but after
    I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyhow, just wanted to
    say superb blog!

  5. Greate article. Keep posting such kind of info on your page.
    Im really impressed by your blog.
    Hello there, You have done an excellent job. I’ll certainly digg it
    and individually recommend to my friends. I am sure they will be benefited from this website.

  6. I don’t even know how I finished up here, but I thought this
    post was once great. I do not realize who you are however certainly you are going to a famous blogger if you happen to
    aren’t already. Cheers!

  7. Attractive section of content. I simply stumbled upon your
    site and in accession capital to assert that I acquire in fact loved account your weblog posts.
    Any way I’ll be subscribing in your augment or even I achievement you get right of entry to
    constantly fast.

  8. Neat blog! Is your theme custom made or did you download it from
    somewhere? A design like yours with a few simple
    adjustements would really make my blog shine.
    Please let me know where you got your design. Many thanks

  9. Hi i am kavin, itѕ my first ocсasi᧐n to commenting anyᴡherе, when i read thiѕ post i tһought i could also make comment due to thiѕ good post.

Leave a Reply

Your email address will not be published.