From 4a9b687a031c38ea514278fd0103238d4bba58eb Mon Sep 17 00:00:00 2001 From: MH Johnson Date: Fri, 2 Aug 2019 14:16:34 -0400 Subject: [PATCH] [Material] FAB refactor - remove unnecessary IconTheme (#37269) * Remove unneeded IconTheme from FAB --- .../src/material/floating_action_button.dart | 15 ++------------- .../material/floating_action_button_test.dart | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index 3100a5729a..c7a4c77f6b 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -431,18 +431,7 @@ class FloatingActionButton extends StatelessWidget { ?? floatingActionButtonTheme.shape ?? (isExtended ? _defaultExtendedShape : _defaultShape); - Widget result; - - if (child != null) { - result = IconTheme.merge( - data: IconThemeData( - color: foregroundColor, - ), - child: child, - ); - } - - result = RawMaterialButton( + Widget result = RawMaterialButton( onPressed: onPressed, elevation: elevation, focusElevation: focusElevation, @@ -458,7 +447,7 @@ class FloatingActionButton extends StatelessWidget { shape: shape, clipBehavior: clipBehavior ?? Clip.none, focusNode: focusNode, - child: result, + child: child, ); if (tooltip != null) { diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index 5be827065d..5a35bb0fb1 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -781,6 +781,23 @@ void main() { ), ); }, semanticsEnabled: true); + + testWidgets('Foreground color applies to icon on fab', (WidgetTester tester) async { + const Color foregroundColor = Color(0xcafefeed); + + await tester.pumpWidget(MaterialApp( + home: FloatingActionButton( + onPressed: () {}, + foregroundColor: foregroundColor, + child: const Icon(Icons.access_alarm), + ), + )); + + final RichText iconRichText = tester.widget( + find.descendant(of: find.byIcon(Icons.access_alarm), matching: find.byType(RichText)), + ); + expect(iconRichText.text.style.color, foregroundColor); + }); } Offset _rightEdgeOfFab(WidgetTester tester) {