Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dc9c62a4
Unverified
Commit
dc9c62a4
authored
Oct 30, 2021
by
Darren Austin
Committed by
GitHub
Oct 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed primaryVariant from usage by the SnackBar. (#92443)
parent
0c9a4205
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+1
-3
snack_bar_test.dart
packages/flutter/test/material/snack_bar_test.dart
+39
-0
No files found.
packages/flutter/lib/src/material/snack_bar.dart
View file @
dc9c62a4
...
...
@@ -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
.
primary
Variant
:
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
,
...
...
packages/flutter/test/material/snack_bar_test.dart
View file @
dc9c62a4
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment