• Burak İmdat's avatar
    Fix `subtitleTextStyle.color` isn't applied to the `ListTile.subtitle` in Material 2 (#133422) · cd9a257d
    Burak İmdat authored
    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
    
    <details>
      <summary>Title Text Style</summary>
      
      ###  All Code
      
      ```dart
      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
      
      ```dart
      final Color? titleColor = effectiveColor;
      ```
    </details>
    
    <details>
      <summary>Subtitle Text Style</summary>
      
      ## All Code
      
      ```dart
      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
      
      ```dart
      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`
    </details>
    
    <details>
      <summary>Problem solved code</summary>
      
      ## All Code
      
      ```dart
      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!,
          );
      ```
    </details>
    
    <details>
    <summary>Screenshot of the result after making the necessary change</summary>
    <img src="https://github.com/flutter/flutter/assets/70351342/b552fd4c-fdcd-4bf5-b4ba-d6b2cfe527cc" width=250>
    </details>
    
    #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].*
    cd9a257d
Name
Last commit
Last update
.github Loading commit data...
.vscode Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.ci.yaml Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CODEOWNERS Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
PATENT_GRANT Loading commit data...
README.md Loading commit data...
TESTOWNERS Loading commit data...
analysis_options.yaml Loading commit data...
dartdoc_options.yaml Loading commit data...
flutter_console.bat Loading commit data...