From 90ca81524226ccbd0b09a444199a2fe848701c2f Mon Sep 17 00:00:00 2001 From: xster Date: Fri, 20 Apr 2018 17:14:03 -0700 Subject: [PATCH] Make bottom app bar safe area friendly (#16820) --- .../lib/src/material/bottom_app_bar.dart | 4 +++- .../test/material/bottom_app_bar_test.dart | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index 515bea7b75..6aef12aa8a 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -106,7 +106,9 @@ class _BottomAppBarState extends State { color: widget.color ?? Theme.of(context).bottomAppBarColor, child: new Material( type: MaterialType.transparency, - child: widget.child, + child: widget.child == null + ? null + : new SafeArea(child: widget.child), ), ); } diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index 17489fb4bf..492694c8de 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -125,6 +125,30 @@ void main() { // // Cannot test this before https://github.com/flutter/flutter/pull/14368 // as there is no way to make the FAB and BAB overlap. + + testWidgets('observes safe area', (WidgetTester tester) async { + await tester.pumpWidget( + new MaterialApp( + home: const MediaQuery( + data: const MediaQueryData( + padding: const EdgeInsets.all(50.0), + ), + child: const Scaffold( + bottomNavigationBar: const BottomAppBar( + child: const Center( + child: const Text('safe'), + ), + ), + ), + ), + ), + ); + + expect( + tester.getBottomLeft(find.widgetWithText(Center, 'safe')), + const Offset(50.0, 550.0), + ); + }); } // The bottom app bar clip path computation is only available at paint time.