Skip to content

Conversation

@777genius
Copy link
Contributor

@777genius 777genius commented Nov 19, 2025

Description

This PR fixes ThemeData.dividerColor to return the correct color that matches what the Divider widget actually renders in Material 2 and Material 3.

Problem

ThemeData.dividerColor returned different values depending on how the theme was created, causing inconsistency with the actual Divider widget color:

  • ThemeData() with M3 returned outline instead of outlineVariant
  • ThemeData.from() with M3 returned M2 value onSurface.withOpacity(0.12) instead of M3 value outlineVariant
  • Divider widget always correctly used outlineVariant in M3

This created confusion for developers who expected Theme.of(context).dividerColor to match the actual divider color they saw on screen.

Solution

Updated both ThemeData() and ThemeData.from() constructors to use the correct divider colors per Material Design specifications:

  • Material 2: ColorScheme.onSurface.withOpacity(0.12) (unchanged)
  • Material 3: ColorScheme.outlineVariant (fixed)

Now all theme creation methods return the correct dividerColor that matches what the Divider widget actually renders.

Testing

Added 4 comprehensive tests that verify:

  • M3: dividerColor equals outlineVariant for all theme creation methods
  • M3: dividerColor matches actual Divider widget color
  • M2: dividerColor equals onSurface.withOpacity(0.12) and matches actual Divider widget color

Related Issues

Fixes #117755

Pre-launch Checklist

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Nov 19, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an inconsistency in the dividerColor for Material 2 and Material 3 themes in Flutter. The changes ensure that ThemeData.dividerColor uses colorScheme.outlineVariant for M3 themes, as per the Material Design specification, across different ThemeData constructors. The M2 behavior is preserved. The pull request also includes a comprehensive set of tests to verify this consistency. The changes are correct and well-tested, but I have one suggestion to improve the robustness of one of the new tests.

@777genius 777genius force-pushed the fix-divider-color-m3-117755 branch from 98b18eb to d9f760a Compare November 19, 2025 20:29
Updated ThemeData constructors to use correct divider colors per
Material Design specifications:
- M2: onSurface.withOpacity(0.12)
- M3: outlineVariant

This ensures Theme.dividerColor matches actual Divider widget color
and eliminates confusion between theme creation methods.

The issue was that ThemeData.dividerColor returned different values
depending on how the theme was created:
- ThemeData() with M3 returned 'outline' (incorrect)
- ThemeData.from() with M3 returned 'onSurface.withOpacity(0.12)' (M2 value, incorrect)
- Divider widget always used 'outlineVariant' in M3 (correct)

Now all theme creation methods return the correct dividerColor that
matches what the Divider widget actually renders.

Fixes flutter#117755
@777genius 777genius force-pushed the fix-divider-color-m3-117755 branch from d9f760a to 7c5c1d3 Compare November 19, 2025 21:00
@dkwingsmt dkwingsmt self-requested a review November 26, 2025 19:25
@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Divider Color Inconsistencies

1 participant