Unverified Commit a1a5c149 authored by Bencze Balázs's avatar Bencze Balázs Committed by GitHub

Add actionsOverflowAlignment parameter to dialog (#95995)

parent f4fc2c87
......@@ -261,6 +261,7 @@ class AlertDialog extends StatelessWidget {
this.actions,
this.actionsPadding = EdgeInsets.zero,
this.actionsAlignment,
this.actionsOverflowAlignment,
this.actionsOverflowDirection,
this.actionsOverflowButtonSpacing,
this.buttonPadding,
......@@ -375,6 +376,21 @@ class AlertDialog extends StatelessWidget {
/// is used.
final MainAxisAlignment? actionsAlignment;
/// The horizontal alignment of [actions] within the vertical
/// "overflow" layout.
///
/// If the dialog's [actions] do not fit into a single row, then they
/// are arranged in a column. This parameter controls the horizontal
/// alignment of widgets in the case of an overflow.
///
/// If this parameter is null (the default) then [OverflowBarAlignment.end]
/// is used.
///
/// See also:
///
/// * [OverflowBar], which [actions] configures to lay itself out.
final OverflowBarAlignment? actionsOverflowAlignment;
/// The vertical direction of [actions] if the children overflow
/// horizontally.
///
......@@ -535,7 +551,7 @@ class AlertDialog extends StatelessWidget {
child: OverflowBar(
alignment: actionsAlignment ?? MainAxisAlignment.end,
spacing: spacing,
overflowAlignment: OverflowBarAlignment.end,
overflowAlignment: actionsOverflowAlignment ?? OverflowBarAlignment.end,
overflowDirection: actionsOverflowDirection ?? VerticalDirection.down,
overflowSpacing: actionsOverflowButtonSpacing ?? 0,
children: actions!,
......
......@@ -1184,6 +1184,40 @@ void main() {
expect(buttonOneRect.bottom, buttonTwoRect.top - 10.0);
});
testWidgets('Dialogs can set the alignment of the OverflowBar', (WidgetTester tester) async {
final GlobalKey key1 = GlobalKey();
final GlobalKey key2 = GlobalKey();
final AlertDialog dialog = AlertDialog(
title: const Text('title'),
content: const Text('content'),
actions: <Widget>[
ElevatedButton(
key: key1,
onPressed: () {},
child: const Text('Loooooooooog button 1'),
),
ElevatedButton(
key: key2,
onPressed: () {},
child: const Text('Loooooooooooooonger button 2'),
),
],
actionsOverflowAlignment: OverflowBarAlignment.center,
);
await tester.pumpWidget(
_buildAppWithDialog(dialog),
);
await tester.tap(find.text('X'));
await tester.pumpAndSettle();
final Rect buttonOneRect = tester.getRect(find.byKey(key1));
final Rect buttonTwoRect = tester.getRect(find.byKey(key2));
expect(buttonOneRect.center.dx, buttonTwoRect.center.dx);
});
testWidgets('Dialogs removes MediaQuery padding and view insets', (WidgetTester tester) async {
late BuildContext outerContext;
late BuildContext routeContext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment