Removed primaryVariant from usage by the SnackBar. (#92443)
This commit is contained in:
parent
0c9a420583
commit
dc9c62a45f
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user