Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change ThemeData #3

Closed
Atulin opened this issue Aug 20, 2018 · 2 comments
Closed

Cannot change ThemeData #3

Atulin opened this issue Aug 20, 2018 · 2 comments

Comments

@Atulin
Copy link

Atulin commented Aug 20, 2018

My MyApp class

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new DynamicTheme(
      defaultBrightness: Brightness.light,
      data: (brightness) => new ThemeData(
        brightness: brightness,
      ),
      themedWidgetBuilder: (context, theme) {
        return new MaterialApp(
          title: 'Omnibus',
          theme: theme,
          home: new SplashScreen(
            title: 'Omnibus',
          ),
        );
      },
    );
  }
}

How I'm changing the theme:

new IconButton(
  icon: new Icon(Icons.palette),
  color: Color.fromARGB(255, 15, 84, 108),
  onPressed: (){
    DynamicTheme.of(context).setBrightness(Brightness.dark);    
    DynamicTheme.of(context).setThemeData(new ThemeData(
      primaryColor: Color.fromARGB(255, 15, 84, 108),
      accentColor: Colors.yellow,
    ));
  }
),

The brightness is being changed properly, however the primary color or the accent color are not.

@Norbert515
Copy link
Owner

The setBrightness is just a convenient method because it's the most common use case. Try this:

                  DynamicTheme.of(context).setThemeData(new ThemeData(
                    brightness: Brightness.dark,
                    primaryColor: Color.fromARGB(255, 15, 84, 108),
                    accentColor: Colors.yellow,
                  ));

@Atulin
Copy link
Author

Atulin commented Aug 20, 2018

Works perfectly, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants