diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index 209753a4bd..4502f2bb10 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -150,6 +150,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { this.flexibleSpace, this.bottom, this.elevation, + this.shape, this.backgroundColor, this.brightness, this.iconTheme, @@ -286,6 +287,12 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { /// for app bars. final double elevation; + /// The material's shape as well its shadow. + /// + /// A shadow is only displayed if the [elevation] is greater than + /// zero. + final ShapeBorder shape; + /// The color to use for the app bar's material. Typically this should be set /// along with [brightness], [iconTheme], [textTheme]. /// @@ -583,6 +590,7 @@ class _AppBarState extends State { elevation: widget.elevation ?? appBarTheme.elevation ?? _defaultElevation, + shape: widget.shape, child: Semantics( explicitChildNodes: true, child: appBar, diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 4f712fd3a2..8459d20758 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -1485,4 +1485,33 @@ void main() { await gesture.up(); await tester.pump(); }); + + testWidgets('AppBar with shape', (WidgetTester tester) async { + const RoundedRectangleBorder roundedRectangleBorder = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15.0))); + await tester.pumpWidget( + MaterialApp( + home: AppBar( + leading: const Text('L'), + title: const Text('No Scaffold'), + shape: roundedRectangleBorder, + actions: const [Text('A1'), Text('A2')], + ), + ), + ); + + final Finder appBarFinder = find.byType(AppBar); + + AppBar getAppBarWidget() { + return tester.widget(appBarFinder); + } + + expect(getAppBarWidget().shape, roundedRectangleBorder); + + final Finder materialFinder = find.byType(Material); + Material getMaterialWidget() { + return tester.widget(materialFinder); + } + + expect(getMaterialWidget().shape, roundedRectangleBorder); + }); }