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
7d707b06
Unverified
Commit
7d707b06
authored
Jul 08, 2021
by
Rick Krystianne Lim
Committed by
GitHub
Jul 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing SnackBar's default vertical padding (#78133)
parent
1a0d873e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+24
-5
snack_bar_test.dart
packages/flutter/test/material/snack_bar_test.dart
+2
-3
No files found.
packages/flutter/lib/src/material/snack_bar.dart
View file @
7d707b06
...
...
@@ -296,10 +296,29 @@ class SnackBar extends StatefulWidget {
/// The amount of padding to apply to the snack bar's content and optional
/// action.
///
/// If this property is null, then the default depends on the [behavior] and
/// the presence of an [action]. The start padding is 24 if [behavior] is
/// [SnackBarBehavior.fixed] and 16 if it is [SnackBarBehavior.floating]. If
/// there is no [action], the same padding is added to the end.
/// If this property is null, the default padding values for:
///
/// * [content]
/// * Top and bottom paddings are 14.
/// * Left padding is 24 if [behavior] is [SnackBarBehavior.fixed],
/// 16 if [behavior] is [SnackBarBehavior.floating]
/// * Right padding is same as start padding if there is no [action], otherwise 0.
/// * [action]
/// * Top and bottom paddings are 14
/// * Left and right paddings are half of [content]'s left padding.
///
/// If this property is not null, the padding assignment for:
///
/// * [content]
/// * Left, top and bottom paddings are assigned normally.
/// * Right padding is assigned normally if there is no [action], otherwise 0.
/// * [action]
/// * Left padding is replaced with half value of right padding.
/// * Top and bottom paddings are assigned normally.
/// * Right padding has an additional half value of right padding.
/// ```dart
/// right + (right / 2)
/// ```
final
EdgeInsetsGeometry
?
padding
;
/// The width of the snack bar.
...
...
@@ -523,7 +542,7 @@ class _SnackBarState extends State<SnackBar> {
children:
<
Widget
>[
Expanded
(
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
_singleLineVerticalPadding
)
,
padding:
widget
.
padding
==
null
?
const
EdgeInsets
.
symmetric
(
vertical:
_singleLineVerticalPadding
)
:
null
,
child:
DefaultTextStyle
(
style:
contentTextStyle
!,
child:
widget
.
content
,
...
...
packages/flutter/test/material/snack_bar_test.dart
View file @
7d707b06
...
...
@@ -978,9 +978,8 @@ void main() {
final
Offset
snackBarTopRight
=
tester
.
getTopRight
(
materialFinder
);
expect
(
textBottomLeft
.
dx
-
snackBarBottomLeft
.
dx
,
padding
);
expect
(
snackBarTopRight
.
dx
-
textTopRight
.
dx
,
padding
);
// The text is given a vertical padding of 14 already.
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
padding
+
14
);
expect
(
textTopRight
.
dy
-
snackBarTopRight
.
dy
,
padding
+
14
);
expect
(
snackBarBottomLeft
.
dy
-
textBottomLeft
.
dy
,
padding
);
expect
(
textTopRight
.
dy
-
snackBarTopRight
.
dy
,
padding
);
});
testWidgets
(
'Snackbar width can be customized'
,
(
WidgetTester
tester
)
async
{
...
...
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