mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Changing SnackBar's default vertical padding (#78133)
This commit is contained in:
parent
1a0d873e2e
commit
7d707b06e8
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue