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
bc56a7a6
Unverified
Commit
bc56a7a6
authored
Oct 25, 2018
by
jslavitz
Committed by
GitHub
Oct 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Snack color (#23255)
* added test
parent
b715cf14
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+11
-0
snack_bar_test.dart
packages/flutter/test/material/snack_bar_test.dart
+44
-0
No files found.
packages/flutter/lib/src/material/snack_bar.dart
View file @
bc56a7a6
...
...
@@ -81,12 +81,21 @@ class SnackBarAction extends StatefulWidget {
/// The [label] and [onPressed] arguments must be non-null.
const
SnackBarAction
({
Key
key
,
this
.
textColor
,
this
.
disabledTextColor
,
@required
this
.
label
,
@required
this
.
onPressed
,
})
:
assert
(
label
!=
null
),
assert
(
onPressed
!=
null
),
super
(
key:
key
);
/// The button label color. If not provided, defaults to [accentColor].
final
Color
textColor
;
/// The button disabled label color. This color is shown after the
/// [snackBarAction] is dismissed.
final
Color
disabledTextColor
;
/// The button label.
final
String
label
;
...
...
@@ -118,6 +127,8 @@ class _SnackBarActionState extends State<SnackBarAction> {
return
FlatButton
(
onPressed:
_haveTriggeredAction
?
null
:
_handlePressed
,
child:
Text
(
widget
.
label
),
textColor:
widget
.
textColor
,
disabledTextColor:
widget
.
disabledTextColor
,
);
}
}
...
...
packages/flutter/test/material/snack_bar_test.dart
View file @
bc56a7a6
...
...
@@ -296,6 +296,50 @@ void main() {
expect
(
tapCount
,
equals
(
1
));
});
testWidgets
(
'Snackbar labels can be colored'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
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
(
textColor:
Colors
.
lightBlue
,
disabledTextColor:
Colors
.
red
,
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
Element
actionTextBox
=
tester
.
element
(
find
.
text
(
'ACTION'
));
final
Widget
textWidget
=
actionTextBox
.
widget
;
final
DefaultTextStyle
defaultTextStyle
=
DefaultTextStyle
.
of
(
actionTextBox
);
if
(
textWidget
is
Text
)
{
TextStyle
effectiveStyle
=
textWidget
.
style
;
effectiveStyle
=
defaultTextStyle
.
style
.
merge
(
textWidget
.
style
);
expect
(
effectiveStyle
.
color
,
Colors
.
lightBlue
);
}
else
expect
(
false
,
true
);
});
testWidgets
(
'SnackBar button text alignment'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
...
...
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