Unverified Commit dc9c62a4 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Removed primaryVariant from usage by the SnackBar. (#92443)

parent 0c9a4205
......@@ -421,7 +421,7 @@ class _SnackBarState extends State<SnackBar> {
final ColorScheme colorScheme = theme.colorScheme;
final SnackBarThemeData snackBarTheme = theme.snackBarTheme;
final bool isThemeDark = theme.brightness == Brightness.dark;
final Color buttonColor = isThemeDark ? colorScheme.primaryVariant : colorScheme.secondary;
final Color buttonColor = isThemeDark ? colorScheme.primary : colorScheme.secondary;
// SnackBar uses a theme that is the opposite brightness from
// the surrounding theme.
......@@ -433,8 +433,6 @@ class _SnackBarState extends State<SnackBar> {
colorScheme: ColorScheme(
primary: colorScheme.onPrimary,
primaryVariant: colorScheme.onPrimary,
// For the button color, the spec says it should be primaryVariant, but for
// backward compatibility on light themes we are leaving it as secondary.
secondary: buttonColor,
secondaryVariant: colorScheme.onSecondary,
surface: colorScheme.onSurface,
......
......@@ -667,6 +667,45 @@ void main() {
expect(renderModel.color, equals(darkTheme.colorScheme.onSurface));
});
testWidgets('Dark theme SnackBar has primary text buttons', (WidgetTester tester) async {
final ThemeData darkTheme = ThemeData.dark();
await tester.pumpWidget(
MaterialApp(
theme: darkTheme,
home: Scaffold(
body: Builder(
builder: (BuildContext context) {
return GestureDetector(
onTap: () {
Scaffold.of(context).showSnackBar(
SnackBar(
content: const Text('I am a snack bar.'),
duration: const Duration(seconds: 2),
action: SnackBarAction(
label: 'ACTION',
onPressed: () { },
),
),
);
},
child: const Text('X'),
);
},
),
),
),
);
await tester.tap(find.text('X'));
await tester.pump(); // start animation
await tester.pump(const Duration(milliseconds: 750));
final TextStyle buttonTextStyle = tester.widget<RichText>(
find.descendant(of: find.text('ACTION'), matching: find.byType(RichText))
).text.style!;
expect(buttonTextStyle.color, equals(darkTheme.colorScheme.primary));
});
testWidgets('SnackBar should inherit theme data from its ancestor.', (WidgetTester tester) async {
final SliderThemeData sliderTheme = SliderThemeData.fromPrimaryColors(
primaryColor: Colors.black,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment