Add alignment parameter for persistentFooterButtons
(#101297)
This commit is contained in:
parent
44be0b84ba
commit
638aae7b76
@ -1463,6 +1463,7 @@ class Scaffold extends StatefulWidget {
|
||||
this.floatingActionButtonLocation,
|
||||
this.floatingActionButtonAnimator,
|
||||
this.persistentFooterButtons,
|
||||
this.persistentFooterAlignment = AlignmentDirectional.centerEnd,
|
||||
this.drawer,
|
||||
this.onDrawerChanged,
|
||||
this.endDrawer,
|
||||
@ -1569,6 +1570,11 @@ class Scaffold extends StatefulWidget {
|
||||
/// [bottomNavigationBar] but below the [body].
|
||||
final List<Widget>? persistentFooterButtons;
|
||||
|
||||
/// The alignment of the [persistentFooterButtons] inside the [OverflowBar].
|
||||
///
|
||||
/// Defaults to [AlignmentDirectional.centerEnd].
|
||||
final AlignmentDirectional persistentFooterAlignment;
|
||||
|
||||
/// A panel displayed to the side of the [body], often hidden on mobile
|
||||
/// devices. Swipes in from either left-to-right ([TextDirection.ltr]) or
|
||||
/// right-to-left ([TextDirection.rtl])
|
||||
@ -2725,7 +2731,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
top: false,
|
||||
child: IntrinsicHeight(
|
||||
child: Container(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
alignment: widget.persistentFooterAlignment,
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: OverflowBar(
|
||||
spacing: 8,
|
||||
|
@ -533,6 +533,41 @@ void main() {
|
||||
expect(didPressButton, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Persistent bottom buttons alignment', (WidgetTester tester) async {
|
||||
Widget buildApp(AlignmentDirectional persistentAligment) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
color: Colors.amber[500],
|
||||
height: 5000.0,
|
||||
child: const Text('body'),
|
||||
),
|
||||
),
|
||||
persistentFooterAlignment: persistentAligment,
|
||||
persistentFooterButtons: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () { },
|
||||
child: const Text('X'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildApp(AlignmentDirectional.centerEnd));
|
||||
Finder footerButton = find.byType(TextButton);
|
||||
expect(tester.getTopRight(footerButton).dx, 800.0 - 8.0);
|
||||
|
||||
await tester.pumpWidget(buildApp(AlignmentDirectional.center));
|
||||
footerButton = find.byType(TextButton);
|
||||
expect(tester.getCenter(footerButton).dx, 800.0 / 2);
|
||||
|
||||
await tester.pumpWidget(buildApp(AlignmentDirectional.centerStart));
|
||||
footerButton = find.byType(TextButton);
|
||||
expect(tester.getTopLeft(footerButton).dx, 8.0);
|
||||
});
|
||||
|
||||
testWidgets('Persistent bottom buttons apply media padding', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
|
Loading…
x
Reference in New Issue
Block a user