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

Idea : Improving theme discover-ability #17013

Closed
Rockvole opened this issue Apr 26, 2018 · 5 comments
Closed

Idea : Improving theme discover-ability #17013

Rockvole opened this issue Apr 26, 2018 · 5 comments
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@Rockvole
Copy link

Rockvole commented Apr 26, 2018

I am halfway through my second flutter app and its starting to dawn on me that the Theme system is actually pretty neat. Whenever I have tried to use Themes before they have not worked as expected (mostly due to not finding the correct keywords) and so I gave up and littered my code with color constants and such.

I think with some tweaking the themes could become the default way of changing styles.
By partitioning ThemeData we can use keywords which are consistent :

    new MaterialApp(
      appBarThemeData : new AppBarThemeData(backgroundColor: Colors.orange),
      scaffoldThemeData : new ScaffoldThemeData(backgroundColor: Colors.green, 
                                                fontSize: 18.0),
      accentThemeData: new AccentThemeData(color: Colors.yellow),
      primaryThemeData: new PrimaryThemeData(colorDark: Colors.slategray)
    )

When wrapping Widgets in Themes the scaffold and the scaffold appBar will take on the theme from the parent ThemeData :

    new Theme(
      scaffoldThemeData: new ScaffoldThemeData(backgroundColor: Colors.purple),
      appBarThemeData: new AppBarThemeData(backgroundColor: Colors.blue),
      new Scaffold(
        appBar: new AppBar(
            title: new Text(widget.title),
          ),
      );
    );

We can also override any part of those themes :

    new Scaffold(
      scaffoldThemeData: new ScaffoldThemeData(backgroundColor: Colors.cyan),
      appBar: new AppBar(
            appBarThemeData: new AppBarThemeData(backgroundColor: Colors.indigo),
            //backgroundColor : Colors.indigo, <- This will be deprecated
            title: new Text(widget.title),
          ),
    );

This would improve the current situation because :

  1. You can use the same themes with the same names throughout your app (use a const ScaffoldThemeData for example)
  2. Improve consistency e.g. Scaffold has a backgroundColor attribute, but in ThemeData it is called scaffoldBackgroundColor
  3. By deprecating all the individual color attributes we ensure devs will be using Themes from the start.

This idea has a similar theme :) to my previous scheme :
Idea: Reduce nesting in Flutter

@Rockvole
Copy link
Author

Here are some issues I found which could be related to (or improved by) my idea :
#16277
#14598
#13962
#12845
#12681
#9148
#3856
#2222

@zoechi zoechi added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jul 26, 2018
@zoechi zoechi added this to the Goals milestone Jan 2, 2019
@Hixie
Copy link
Contributor

Hixie commented Jan 10, 2020

cc @HansMuller this could be useful to you given your work on updating the theming mechanism. Please close this issue once you have taken its suggestions and linked bugs into account (i.e. once it is no longer actionable).

@Rockvole thanks for the ideas!

@HansMuller
Copy link
Contributor

@Rockvole - thanks for all of the suggestions about improving the Material theme system and please accept my apology for not having addressed this issue for such a long time. We are undertaking an long-term project to improve the theme system, it's described here flutter.dev/go/material-theme-system-updates. The doc is open for comments if you're still interested in this topic.

@Rockvole
Copy link
Author

Thanks @HansMuller for taking an interest in my issue.
The document looks like it would provide an improvement. I don't feel confident to provide comments since I have not worked in Flutter for over a year so I am out-of-date with the framework updates (have been part-time on a dart project instead).

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

4 participants