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

Fix subtitleTextStyle.color isn't applied to the ListTile.subtitle in Material 2 #133422

Merged
merged 5 commits into from
Sep 6, 2023

Conversation

burakJs
Copy link
Contributor

@burakJs burakJs commented Aug 28, 2023

The difference between header text style and subtitle text style and the reason why it doesn't work is the code difference below. If we make the subtitle text style the same as the title text style it will work

Title Text Style

All Code

TextStyle titleStyle = titleTextStyle
    ?? tileTheme.titleTextStyle
    ?? defaults.titleTextStyle!;
  final Color? titleColor = effectiveColor;
  titleStyle = titleStyle.copyWith(
    color: titleColor,
    fontSize: _isDenseLayout(theme, tileTheme) ? 13.0 : null,
  );
  final Widget titleText = AnimatedDefaultTextStyle(
    style: titleStyle,
    duration: kThemeChangeDuration,
    child: title ?? const SizedBox(),
  );

Different Code Section

final Color? titleColor = effectiveColor;
Subtitle Text Style

All Code

subtitleStyle = subtitleTextStyle
      ?? tileTheme.subtitleTextStyle
      ?? defaults.subtitleTextStyle!;
    final Color? subtitleColor = effectiveColor
      ?? (theme.useMaterial3 ? null : theme.textTheme.bodySmall!.color);
    subtitleStyle = subtitleStyle.copyWith(
      color: subtitleColor,
      fontSize: _isDenseLayout(theme, tileTheme) ? 12.0 : null,
    );
    subtitleText = AnimatedDefaultTextStyle(
      style: subtitleStyle,
      duration: kThemeChangeDuration,
      child: subtitle!,
    );

Different Code Section

final Color? subtitleColor = effectiveColor
      ?? (theme.useMaterial3 ? null : theme.textTheme.bodySmall!.color);

Description for code

  • The value theme.textTheme.bodySmall!.color is given because the effectiveColor value is null and the theme.useMaterial3 value is false
Problem solved code

All Code

subtitleStyle = subtitleTextStyle
      ?? tileTheme.subtitleTextStyle
      ?? defaults.subtitleTextStyle!;
    final Color? subtitleColor = effectiveColor;
    subtitleStyle = subtitleStyle.copyWith(
      color: subtitleColor,
      fontSize: _isDenseLayout(theme, tileTheme) ? 12.0 : null,
    );
    subtitleText = AnimatedDefaultTextStyle(
      style: subtitleStyle,
      duration: kThemeChangeDuration,
      child: subtitle!,
    );
Screenshot of the result after making the necessary change

#133412

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Aug 28, 2023
@TahaTesser TahaTesser self-requested a review August 28, 2023 12:35
@TahaTesser TahaTesser changed the title Fix SubTitleTextStyle For ListTile Fix subtitleTextStyle.color isn't applied to the ListTile.subtitle in Material 2 Aug 28, 2023
@TahaTesser
Copy link
Member

It looks like there are some test failures.

@burakJs
Copy link
Contributor Author

burakJs commented Aug 28, 2023

It looks like there are some test failures.

I'm investigating and will let you know as soon as possible.

@burakJs
Copy link
Contributor Author

burakJs commented Aug 28, 2023

@TahaTesser

This comment was marked as resolved.

@burakJs

This comment was marked as resolved.

@TahaTesser
Copy link
Member

TahaTesser commented Aug 31, 2023

final Color? subtitleColor = effectiveColor
    ?? (theme.useMaterial3 ? null : theme.textTheme.bodySmall!.color);
  • So why do we change the color property of the subtitleTextStyle given by the user in this code?

textColor & selectedColor overrides both titleTextStyle & subtitleTextStyle, that's effectiveColor

If both text & selectedColor are null, we default to a null value so the recently added subtitleTextStyle's color can be used only for M3 and we default bodySmall color` for backward compatibility.

bodySmall!.color has been used for the subtitle in M2 as the default color and you're changing this default behavior hence the test issues.

If we still want the subtitleTextStyle color for M2 we can do this without the changing M2 default. Please apply the suggested code below and revert the default test update.

@TahaTesser
Copy link
Member

@burakJs
With the updated fix and the default test update revert. This should work without breaking the customer test.

We'll need to test in the list_tile_theme_test.dart to land this. Update existing test if it exists.

@burakJs
Copy link
Contributor Author

burakJs commented Aug 31, 2023

I will make changes and corrections as soon as possible. Thanks for the help and detailed explanation.

@burakJs
Copy link
Contributor Author

burakJs commented Sep 1, 2023

  • I made all the changes you mentioned.
  • All tests in list_tile_theme_test .dart file pass
image

@TahaTesser
Copy link
Member

TahaTesser commented Sep 1, 2023

#133422 (comment)

We'll need to test in the list_tile_theme_test.dart to land this. Update existing test if it exists.

Hey @burakJs
Since you're a new contributor. I've improved tests for M3 and added tests for the M2 to land this PR.
I also updated the fix itself to be much more straightforward and pushed changes myself.
I'd advise you to take a look at the changes I've made for future potential PRs.

Thank you for raising this PR.

Copy link
Member

@TahaTesser TahaTesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TahaTesser
Copy link
Member

This will need a second review from @HansMuller before we land.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HansMuller HansMuller added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 6, 2023
@auto-submit auto-submit bot merged commit cd9a257 into flutter:master Sep 6, 2023
67 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 7, 2023
…4870)

Manual roll Flutter from 685ce14b2d0f to aea4552acdc7 (64 revisions)

Manual roll requested by dit@google.com

flutter/flutter@685ce14...aea4552

2023-09-07 andrewrkolos@gmail.com add --exit flag to dev/devicelab/bin/test_runner.dart (flutter/flutter#134165)
2023-09-07 andrewrkolos@gmail.com fix `--exit` flag in dev/devicelab/bin/run.dart (flutter/flutter#134162)
2023-09-07 engine-flutter-autoroll@skia.org Roll Packages from e7d812c to 22d4754 (9 revisions) (flutter/flutter#134232)
2023-09-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 71bea01d3abe to f0b718e28779 (2 revisions) (flutter/flutter#134231)
2023-09-07 polinach@google.com DropdownRoutePage should dispose the created ScrollController. (flutter/flutter#133941)
2023-09-07 sokolovskyi.konstantin@gmail.com Cover some test/widgets tests with leak tracking (flutter/flutter#133803)
2023-09-07 polinach@google.com SearchDelegate should dispose resources. (flutter/flutter#133948)
2023-09-07 matheus@btor.com.br Fixed [NavigationRailDestination]'s label opacity while disabled not being coherent with the icon (flutter/flutter#132345)
2023-09-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 558136a1ccbf to 71bea01d3abe (2 revisions) (flutter/flutter#134216)
2023-09-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5a45ecd24aa3 to 558136a1ccbf (1 revision) (flutter/flutter#134206)
2023-09-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from d864ae68db3c to 5a45ecd24aa3 (1 revision) (flutter/flutter#134201)
2023-09-07 tessertaha@gmail.com Fix `TabBar` doesn't use `labelStyle` & `unselectedLabelStyle` color (flutter/flutter#133989)
2023-09-07 tessertaha@gmail.com Fix `DataTable`'s `headingTextStyle` & `dataTextStyle` are not merged with default text style (flutter/flutter#134138)
2023-09-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 187c5b3c5f71 to d864ae68db3c (2 revisions) (flutter/flutter#134199)
2023-09-07 tessertaha@gmail.com Reland "Fix `Chip.shape`'s side is not used when provided in Material 3" (flutter/flutter#133856)
2023-09-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 75437a3bd002 to 187c5b3c5f71 (1 revision) (flutter/flutter#134193)
2023-09-07 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 2c69d05dfafb to 75437a3bd002 (15 revisions) (flutter/flutter#134188)
2023-09-07 zanderso@users.noreply.github.com Revert "Roll Flutter Engine from 2c69d05dfafb to fa14d337449b (6 revisions)" (flutter/flutter#134183)
2023-09-06 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 3.1.2 to 3.1.3 (flutter/flutter#134173)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2c69d05dfafb to fa14d337449b (6 revisions) (flutter/flutter#134169)
2023-09-06 polinach@google.com DraggableScrollableActuator should dispose notifier. (flutter/flutter#133917)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from b04c2a378302 to 2c69d05dfafb (3 revisions) (flutter/flutter#134164)
2023-09-06 polinach@google.com Clean the fixed TODOs. (flutter/flutter#133859)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 839051596b1d to b04c2a378302 (7 revisions) (flutter/flutter#134158)
2023-09-06 737941+loic-sharma@users.noreply.github.com [Windows Arm64] Also use Windows 11 for Devicelab tests (flutter/flutter#134082)
2023-09-06 70351342+burakJs@users.noreply.github.com Fix `subtitleTextStyle.color` isn't applied to the `ListTile.subtitle` in Material 2 (flutter/flutter#133422)
2023-09-06 pateltirth454@gmail.com Add `CheckedPopupMenuItem.onTap` callback (flutter/flutter#134000)
2023-09-06 polinach@google.com MinimumTextContrastGuideline should dispose image. (flutter/flutter#133861)
2023-09-06 christopherfujino@gmail.com [flutter_tools] Fix "FormatException: Invalid date format" during version freshness check (flutter/flutter#134088)
2023-09-06 polinach@google.com Fix not disposed items in Cupertino app and route. (flutter/flutter#134085)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from a5e7fa6bf81a to 839051596b1d (2 revisions) (flutter/flutter#134140)
2023-09-06 polinach@google.com _DropdownMenuState should dispose TextEditingController. (flutter/flutter#133914)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5253a33096d1 to a5e7fa6bf81a (1 revision) (flutter/flutter#134137)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from c7fd088291e2 to 5253a33096d1 (1 revision) (flutter/flutter#134135)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3d9989f1e155 to c7fd088291e2 (1 revision) (flutter/flutter#134132)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from bace539bb654 to 3d9989f1e155 (3 revisions) (flutter/flutter#134128)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9344685efbc3 to bace539bb654 (1 revision) (flutter/flutter#134104)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0c8c1647dcd0 to 9344685efbc3 (1 revision) (flutter/flutter#134103)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0c663258fd09 to 0c8c1647dcd0 (1 revision) (flutter/flutter#134100)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8bacc3b38707 to 0c663258fd09 (3 revisions) (flutter/flutter#134096)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 590349006d23 to 8bacc3b38707 (5 revisions) (flutter/flutter#134089)
2023-09-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5b2cc9d9b8fe to 590349006d23 (2 revisions) (flutter/flutter#134081)
2023-09-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from 98b036ae708e to 5b2cc9d9b8fe (2 revisions) (flutter/flutter#134080)
2023-09-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from f4975e04f35e to 98b036ae708e (3 revisions) (flutter/flutter#134077)
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants