[Material] FAB refactor - remove unnecessary IconTheme (#37269)
* Remove unneeded IconTheme from FAB
This commit is contained in:
parent
5df17acb1f
commit
4a9b687a03
@ -431,18 +431,7 @@ class FloatingActionButton extends StatelessWidget {
|
|||||||
?? floatingActionButtonTheme.shape
|
?? floatingActionButtonTheme.shape
|
||||||
?? (isExtended ? _defaultExtendedShape : _defaultShape);
|
?? (isExtended ? _defaultExtendedShape : _defaultShape);
|
||||||
|
|
||||||
Widget result;
|
Widget result = RawMaterialButton(
|
||||||
|
|
||||||
if (child != null) {
|
|
||||||
result = IconTheme.merge(
|
|
||||||
data: IconThemeData(
|
|
||||||
color: foregroundColor,
|
|
||||||
),
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = RawMaterialButton(
|
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
elevation: elevation,
|
elevation: elevation,
|
||||||
focusElevation: focusElevation,
|
focusElevation: focusElevation,
|
||||||
@ -458,7 +447,7 @@ class FloatingActionButton extends StatelessWidget {
|
|||||||
shape: shape,
|
shape: shape,
|
||||||
clipBehavior: clipBehavior ?? Clip.none,
|
clipBehavior: clipBehavior ?? Clip.none,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
child: result,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tooltip != null) {
|
if (tooltip != null) {
|
||||||
|
@ -781,6 +781,23 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}, semanticsEnabled: true);
|
}, 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<RichText>(
|
||||||
|
find.descendant(of: find.byIcon(Icons.access_alarm), matching: find.byType(RichText)),
|
||||||
|
);
|
||||||
|
expect(iconRichText.text.style.color, foregroundColor);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Offset _rightEdgeOfFab(WidgetTester tester) {
|
Offset _rightEdgeOfFab(WidgetTester tester) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user