Fix InputDecorationTheme copyWith fallback for iconColor (#142462)

Same as https://github.com/flutter/flutter/pull/138914, but with a test.
This commit is contained in:
Michael Goderbauer 2024-01-29 11:15:22 -08:00 committed by GitHub
parent fd7f45a8be
commit c576f0039d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -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,

View file

@ -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)));
});
}