From 567267969dfe3c1df0c43ed952544bf1f02cb367 Mon Sep 17 00:00:00 2001 From: Darren Austin Date: Thu, 13 May 2021 13:04:04 -0700 Subject: [PATCH] Fixed a problem with the FAB position if a maximum width was set on the bottom sheet of a scaffold. (#82234) --- packages/flutter/lib/src/material/bottom_sheet.dart | 1 + .../flutter/test/material/bottom_sheet_test.dart | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 6010b63a0a..81913f25c2 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -283,6 +283,7 @@ class _BottomSheetState extends State { if (constraints != null) { bottomSheet = Align( alignment: Alignment.bottomCenter, + heightFactor: 1.0, child: ConstrainedBox( constraints: constraints, child: bottomSheet, diff --git a/packages/flutter/test/material/bottom_sheet_test.dart b/packages/flutter/test/material/bottom_sheet_test.dart index 7db0d42026..05845093e3 100644 --- a/packages/flutter/test/material/bottom_sheet_test.dart +++ b/packages/flutter/test/material/bottom_sheet_test.dart @@ -910,9 +910,10 @@ void main() { constraints: BoxConstraints(maxWidth: 80), ), ), - home: const Scaffold( - body: Center(child: Text('body')), - bottomSheet: Text('BottomSheet'), + home: Scaffold( + body: const Center(child: Text('body')), + bottomSheet: const Text('BottomSheet'), + floatingActionButton: FloatingActionButton(onPressed: () {}, child: const Icon(Icons.add)), ), )); expect(find.text('BottomSheet'), findsOneWidget); @@ -921,6 +922,12 @@ void main() { tester.getRect(find.text('BottomSheet')), const Rect.fromLTRB(360, 558, 440, 600), ); + // Ensure the FAB is overlapping the top of the sheet + expect(find.byIcon(Icons.add), findsOneWidget); + expect( + tester.getRect(find.byIcon(Icons.add)), + const Rect.fromLTRB(744, 544, 768, 568), + ); }); testWidgets('Theme constraints used for showBottomSheet', (WidgetTester tester) async {