Norbert515 / dynamic_theme

Dynamically changing your theme without hassle
MIT License
322 stars 69 forks source link

Multiple issues with this plugin #50

Open dancb10 opened 3 years ago

dancb10 commented 3 years ago

Seems like there are some bugs with this plugin, as follows: I'm trying to use it to for a two color theme in my app. The problem si that if you either change the primary or secondary color, the other is changed automatically. This is something that's not desired, each color must be changed regards of the other:

void changeColor() {
    DynamicTheme.of(context).setThemeData(
      new ThemeData(primaryColor: _mainColor, accentColor: _accentColor),
    );
  }

this is the way I change the colors. I load the settings upon reboot and the _mainColor and _accentColor are automatically populated when the app starts so in case you don't change a color, it will retain the old color value. So the problem is that if you change the primaryColor, the plugin will automatically change the accentColor which it's a bug

      child: DynamicTheme(
        defaultBrightness: Brightness.light,
        data: (brightness) => new ThemeData(
          primaryColor: themeSettings != null
              ? Color(themeSettings.mainColor)
              : Colors.teal,
          accentColor: themeSettings != null
              ? Color(themeSettings.accentColor)
              : Colors.grey,
          brightness: brightness,
          fontFamily: 'Georgia',
          textTheme: TextTheme(
            headline1: TextStyle(
              fontSize: 20.0,
              fontWeight: FontWeight.normal,
            ),
            bodyText2: TextStyle(
              fontSize: 15.0,
              color: Colors.black,
            ),
            bodyText1: TextStyle(
              fontSize: 10.0,
              fontStyle: FontStyle.italic,
            ),
          ),
        ),

The second problem is that if you change either the primary or the secondary color, the AppBar text gets broken (the font is changed and increased in size). So these is the screen before I change the color:

Screen Shot 2021-02-01 at 11 59 52 AM

And after changing it (check out the AppBar text):

Screen Shot 2021-02-01 at 12 00 53 PM

If I close and reopen the screen, the font goes back to normal. The AppBar takes the text font from the Dynamic Theme:

    appBar: AppBar(
        title: Text(
          'Theme',
          style: Theme.of(context).textTheme.headline1,
        ),

This is another bug with this plugin