From 7011d30876b0bc20cbb8d13002e54ea0be7e98fb Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 28 Feb 2020 09:51:02 -0800 Subject: [PATCH] AppBar Height Fix (#48761) --- .../flutter/lib/src/material/app_bar.dart | 1 + .../flutter/test/material/app_bar_test.dart | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index e2ff809c92..cff49063ac 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -603,6 +603,7 @@ class _AppBarState extends State { // The padding applies to the toolbar and tabbar, not the flexible space. if (widget.primary) { appBar = SafeArea( + bottom: false, top: true, child: appBar, ); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 3f8cd34578..78f423b595 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -965,6 +965,36 @@ void main() { expect(tester.getTopLeft(find.text('title')).dy, lessThan(100.0)); }); + testWidgets('AppBar in body excludes bottom SafeArea padding', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/26163 + await tester.pumpWidget( + Localizations( + locale: const Locale('en', 'US'), + delegates: const >[ + DefaultMaterialLocalizations.delegate, + DefaultWidgetsLocalizations.delegate, + ], + child: Directionality( + textDirection: TextDirection.ltr, + child: MediaQuery( + data: const MediaQueryData(padding: EdgeInsets.symmetric(vertical: 100.0)), + child: Scaffold( + primary: true, + body: Column( + children: [ + AppBar( + title: const Text('title'), + ), + ], + ), + ), + ), + ), + )); + expect(appBarTop(tester), 0.0); + expect(appBarHeight(tester), kToolbarHeight + 100.0); + }); + testWidgets('AppBar updates when you add a drawer', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp(