@@ -2801,6 +2801,65 @@ void main() {
28012801 // The scrim should be gone.
28022802 expect (findModalBarrier (), findsNothing);
28032803 });
2804+
2805+ testWidgets ("Closing bottom sheet & removing FAB at the same time doesn't throw assertion" , (WidgetTester tester) async {
2806+ final Key bottomSheetKey = UniqueKey ();
2807+ PersistentBottomSheetController <void >? controller;
2808+ bool show = true ;
2809+
2810+ await tester.pumpWidget (StatefulBuilder (
2811+ builder: (_, StateSetter setState) => MaterialApp (
2812+ home: Scaffold (
2813+ body: Center (
2814+ child: Builder (
2815+ builder: (BuildContext context) => ElevatedButton (
2816+ onPressed: () {
2817+ if (controller == null ) {
2818+ controller = showBottomSheet (
2819+ context: context,
2820+ builder: (_) => Container (
2821+ key: bottomSheetKey,
2822+ height: 200 ,
2823+ ),
2824+ );
2825+ } else {
2826+ controller! .close ();
2827+ controller = null ;
2828+ }
2829+ },
2830+ child: const Text ('BottomSheet' ),
2831+ )),
2832+ ),
2833+ floatingActionButton: show
2834+ ? FloatingActionButton (onPressed: () => setState (() => show = false ))
2835+ : null ,
2836+ ),
2837+ ),
2838+ ));
2839+
2840+ // Show bottom sheet.
2841+ await tester.tap (find.byType (ElevatedButton ));
2842+ await tester.pumpAndSettle (const Duration (seconds: 1 ));
2843+
2844+ // Bottom sheet and FAB are visible.
2845+ expect (find.byType (FloatingActionButton ), findsOneWidget);
2846+ expect (find.byKey (bottomSheetKey), findsOneWidget);
2847+
2848+ // Close bottom sheet while removing FAB.
2849+ await tester.tap (find.byType (FloatingActionButton ));
2850+ await tester.pump (); // start animation
2851+ await tester.tap (find.byType (ElevatedButton ));
2852+ // Let the animation finish.
2853+ await tester.pumpAndSettle (const Duration (seconds: 1 ));
2854+
2855+ // Bottom sheet and FAB are gone.
2856+ expect (find.byType (FloatingActionButton ), findsNothing);
2857+ expect (find.byKey (bottomSheetKey), findsNothing);
2858+
2859+ // No exception is thrown.
2860+ expect (tester.takeException (), isNull);
2861+ });
2862+
28042863}
28052864
28062865class _GeometryListener extends StatefulWidget {
0 commit comments