From c576f0039d75716f04f82c8b58ca208c756b9835 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Mon, 29 Jan 2024 11:15:22 -0800 Subject: [PATCH] Fix InputDecorationTheme copyWith fallback for iconColor (#142462) Same as https://github.com/flutter/flutter/pull/138914, but with a test. --- .../flutter/lib/src/material/input_decorator.dart | 2 +- .../flutter/test/material/input_decorator_test.dart | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index d3b3c627e77..85f55f921e1 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -4309,7 +4309,7 @@ class InputDecorationTheme with Diagnosticable { floatingLabelAlignment: floatingLabelAlignment ?? this.floatingLabelAlignment, isDense: isDense ?? this.isDense, contentPadding: contentPadding ?? this.contentPadding, - iconColor: iconColor, + iconColor: iconColor ?? this.iconColor, isCollapsed: isCollapsed ?? this.isCollapsed, prefixStyle: prefixStyle ?? this.prefixStyle, prefixIconColor: prefixIconColor ?? this.prefixIconColor, diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index c1f6c6aa4c9..986d867bbce 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -7047,4 +7047,16 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular await tester.pumpAndSettle(); expect(getLabelStyle(tester).height, beforeStyle.height); }); + + test('InputDecorationTheme.copyWith keeps original iconColor.', () async { + const InputDecorationTheme original = InputDecorationTheme(iconColor: Color(0xDEADBEEF)); + expect(original.iconColor, const Color(0xDEADBEEF)); + expect(original.fillColor, isNot(const Color(0xDEADCAFE))); + final InputDecorationTheme copy1 = original.copyWith(fillColor: const Color(0xDEADCAFE)); + expect(copy1.iconColor, const Color(0xDEADBEEF)); + expect(copy1.fillColor, const Color(0xDEADCAFE)); + final InputDecorationTheme copy2 = original.copyWith(iconColor: const Color(0xDEADCAFE)); + expect(copy2.iconColor, const Color(0xDEADCAFE)); + expect(copy2.fillColor, isNot(const Color(0xDEADCAFE))); + }); }