diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index a09083351a4..52570332cf4 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -1697,6 +1697,7 @@ class Scaffold extends StatefulWidget { this.floatingActionButtonAnimator, this.persistentFooterButtons, this.persistentFooterAlignment = AlignmentDirectional.centerEnd, + this.persistentFooterDecoration, this.drawer, this.onDrawerChanged, this.endDrawer, @@ -1814,6 +1815,17 @@ class Scaffold extends StatefulWidget { /// Defaults to [AlignmentDirectional.centerEnd]. final AlignmentDirectional persistentFooterAlignment; + /// Decoration for the container that holds the [persistentFooterButtons]. + /// + /// By default, this container has a top border with a width of 1.0, created by + /// [Divider.createBorderSide]. + /// + /// See also: + /// + /// * [persistentFooterButtons], which defines the buttons to show in the footer. + /// * [persistentFooterAlignment], which defines the alignment of the footer buttons. + final BoxDecoration? persistentFooterDecoration; + /// 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]) @@ -3058,9 +3070,9 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto _addIfNonNull( children, Container( - decoration: BoxDecoration( - border: Border(top: Divider.createBorderSide(context, width: 1.0)), - ), + decoration: + widget.persistentFooterDecoration ?? + BoxDecoration(border: Border(top: Divider.createBorderSide(context, width: 1.0))), child: SafeArea( top: false, child: IntrinsicHeight( diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 387e6ddbb8e..ba115de8194 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -823,6 +823,33 @@ void main() { expect(initialPoint, finalPoint); }); + testWidgets('Persistent bottom buttons can apply decoration', (WidgetTester tester) async { + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: MediaQuery( + data: const MediaQueryData(padding: EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0)), + child: Scaffold( + body: SingleChildScrollView( + child: Container(color: Colors.amber[500], height: 5000.0, child: const Text('body')), + ), + persistentFooterDecoration: const BoxDecoration( + border: Border(top: BorderSide(color: Colors.red)), + ), + persistentFooterButtons: const [Placeholder()], + ), + ), + ), + ); + + final Finder persistentFooter = + find.ancestor(of: find.byType(OverflowBar), matching: find.byType(Container)).first; + final Decoration decoration = tester.widget(persistentFooter).decoration!; + + expect(decoration, isA()); + expect((decoration as BoxDecoration).border!.top.color, Colors.red); + }); + group('back arrow', () { Future expectBackIcon(WidgetTester tester, IconData expectedIcon) async { final GlobalKey rootKey = GlobalKey();