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

Add bodyFontFamily and displayFontFamily to TextTheme.apply() #148510

Open
martin-braun opened this issue May 16, 2024 · 0 comments · May be fixed by #148603
Open

Add bodyFontFamily and displayFontFamily to TextTheme.apply() #148510

martin-braun opened this issue May 16, 2024 · 0 comments · May be fixed by #148603
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@martin-braun
Copy link

martin-braun commented May 16, 2024

Use case

When calling ThemeData.apply() we are able to define two different colors, separating base text from emphasized large text.

From https://stackoverflow.com/a/49287410/1540350:

bodyColor will be applied to headline, title, subhead, button, body1, and body2. displayColor will be applied to display1 through display4, and caption. If you specify both bodyColor and displayColor and use the same color value, that will effectively change text colors on all text styles.

Example:

final newTextTheme = Theme.of(context).textTheme.apply(
  bodyColor: Colors.pink,
  displayColor: Colors.pink,
);

I like this separation and would enjoy to have the same consistent experience for the font family, however there is only apply's fontFamily, so in order to make this separation with fonts, I have to construct some crazy tree:

  static ThemeData materialLightTheme = ThemeData.light().copyWith(
      colorScheme: ColorScheme.fromSeed(seedColor: envPrimaryColor),
      textTheme: ThemeData.light()
          .textTheme
          .apply(
            fontFamily: envBodyFont,
          )
          .copyWith(
              displaySmall: ThemeData.light().textTheme.displaySmall!.copyWith(
                    fontFamily: envDisplayFont,
                  ),
              displayMedium:
                  ThemeData.light().textTheme.displayMedium!.copyWith(
                        fontFamily: envDisplayFont,
                      ),
              displayLarge: ThemeData.light().textTheme.displayLarge!.copyWith(
                    fontFamily: envDisplayFont,
                  )),
      cupertinoOverrideTheme: CupertinoThemeData(
        primaryColor: envPprimaryColor,
      ));

Ugh, I'm not a fan of that.

Proposal

Something like this would satisfy me:

final newTextTheme = Theme.of(context).textTheme.apply(
  bodyFontFamily: envBodyFont,
  displayFontFamily: envDisplayFont,
);

Only if the specific value is not set, it should fallback to the more generic fontFamily to avoid breaking changes.

Thank you!

@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label May 17, 2024
@danagbemava-nc danagbemava-nc changed the title bodyFontFamily and displayFontFamily on ThemeData.apply() Add bodyFontFamily and displayFontFamily to TextTheme.apply() May 17, 2024
@danagbemava-nc danagbemava-nc added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. c: proposal A detailed proposal for a change to Flutter team-design Owned by Design Languages team and removed in triage Presently being triaged by the triage team labels May 17, 2024
@Piinks Piinks added triaged-design Triaged by Design Languages team P2 Important issues not at the top of the work list waiting for PR to land (fixed) A fix is in flight labels May 22, 2024
@Piinks Piinks added P3 Issues that are less important to the Flutter project and removed P2 Important issues not at the top of the work list waiting for PR to land (fixed) A fix is in flight labels May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants