• 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
..
lib Loading commit data...
test Loading commit data...
test_fixes Loading commit data...
test_private Loading commit data...
test_profile Loading commit data...
test_release Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
analysis_options.yaml Loading commit data...
build.yaml Loading commit data...
dart_test.yaml Loading commit data...
pubspec.yaml Loading commit data...