Skip to content

Commit c576f00

Browse files
authored
Fix InputDecorationTheme copyWith fallback for iconColor (#142462)
Same as flutter/flutter#138914, but with a test.
1 parent fd7f45a commit c576f00

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/flutter/lib/src/material/input_decorator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4309,7 +4309,7 @@ class InputDecorationTheme with Diagnosticable {
43094309
floatingLabelAlignment: floatingLabelAlignment ?? this.floatingLabelAlignment,
43104310
isDense: isDense ?? this.isDense,
43114311
contentPadding: contentPadding ?? this.contentPadding,
4312-
iconColor: iconColor,
4312+
iconColor: iconColor ?? this.iconColor,
43134313
isCollapsed: isCollapsed ?? this.isCollapsed,
43144314
prefixStyle: prefixStyle ?? this.prefixStyle,
43154315
prefixIconColor: prefixIconColor ?? this.prefixIconColor,

packages/flutter/test/material/input_decorator_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7047,4 +7047,16 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular
70477047
await tester.pumpAndSettle();
70487048
expect(getLabelStyle(tester).height, beforeStyle.height);
70497049
});
7050+
7051+
test('InputDecorationTheme.copyWith keeps original iconColor.', () async {
7052+
const InputDecorationTheme original = InputDecorationTheme(iconColor: Color(0xDEADBEEF));
7053+
expect(original.iconColor, const Color(0xDEADBEEF));
7054+
expect(original.fillColor, isNot(const Color(0xDEADCAFE)));
7055+
final InputDecorationTheme copy1 = original.copyWith(fillColor: const Color(0xDEADCAFE));
7056+
expect(copy1.iconColor, const Color(0xDEADBEEF));
7057+
expect(copy1.fillColor, const Color(0xDEADCAFE));
7058+
final InputDecorationTheme copy2 = original.copyWith(iconColor: const Color(0xDEADCAFE));
7059+
expect(copy2.iconColor, const Color(0xDEADCAFE));
7060+
expect(copy2.fillColor, isNot(const Color(0xDEADCAFE)));
7061+
});
70507062
}

0 commit comments

Comments
 (0)