diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index d1fdb66c6f..6d211d88c8 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -210,7 +210,11 @@ class FloatingActionButton extends StatelessWidget { label, const SizedBox(width: 20.0), ] - : [ + : !isExtended ? [ + const SizedBox(width: 20.0), + icon, + const SizedBox(width: 20.0), + ] : [ const SizedBox(width: 16.0), icon, const SizedBox(width: 8.0), diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index e90b014eec..4a07d57049 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -942,6 +942,27 @@ void main() { paints..circle(color: splashColor), ); }); + + testWidgets('extended FAB does not show label when isExtended is false', (WidgetTester tester) async { + const Key iconKey = Key('icon'); + const Key labelKey = Key('label'); + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: FloatingActionButton.extended( + isExtended: false, + label: const Text('', key: labelKey), + icon: const Icon(Icons.add, key: iconKey), + onPressed: () {}, + ), + ), + ); + + // Verify that Icon is present and label is not. + expect(find.byKey(iconKey), findsOneWidget); + expect(find.byKey(labelKey), findsNothing); + }); } Offset _rightEdgeOfFab(WidgetTester tester) {