diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 0243e49ec5..988eecd26b 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -1950,7 +1950,7 @@ class _InputDecoratorState extends State with TickerProviderStat } Color _getHoverColor(ThemeData themeData) { - if (decoration.filled == null || !decoration.filled! || isFocused || !decoration.enabled) { + if (decoration.filled == null || !decoration.filled! || !decoration.enabled) { return Colors.transparent; } return decoration.hoverColor ?? themeData.inputDecorationTheme.hoverColor ?? themeData.hoverColor; diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index e6a9813033..5e3dec436a 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -350,7 +350,7 @@ void main() { ..path( style: PaintingStyle.fill, color: theme.colorScheme.surfaceContainerHighest, - ) + ), ); }); @@ -409,7 +409,7 @@ void main() { ..path( style: PaintingStyle.fill, color: theme.colorScheme.onSurface.withOpacity(0.04), - ) + ), ); }); @@ -470,7 +470,7 @@ void main() { ..path( style: PaintingStyle.fill, color: Color.alphaBlend(theme.hoverColor, theme.colorScheme.surfaceContainerHighest), - ) + ), ); }); @@ -530,7 +530,32 @@ void main() { ..path( style: PaintingStyle.fill, color: theme.colorScheme.surfaceContainerHighest, - ) + ), + ); + }); + + testWidgets('container has correct color when focused and hovered', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/146573. + await tester.pumpWidget( + buildInputDecorator( + isFocused: true, + isHovering: true, + decoration: const InputDecoration( + filled: true, + labelText: labelText, + helperText: helperText, + ), + ), + ); + + final ThemeData theme = Theme.of(tester.element(findDecorator())); + final Color focusColor = theme.colorScheme.surfaceContainerHighest; + final Color hoverColor = theme.hoverColor; + expect(findBorderPainter(), paints + ..path( + style: PaintingStyle.fill, + color: Color.alphaBlend(hoverColor, focusColor), + ), ); }); @@ -607,7 +632,7 @@ void main() { ..path( style: PaintingStyle.fill, color: theme.colorScheme.surfaceContainerHighest, - ) + ), ); }); @@ -729,7 +754,7 @@ void main() { expect(findBorderPainter(), paints ..path( style: PaintingStyle.stroke, - ) + ), ); }); @@ -784,7 +809,7 @@ void main() { expect(findBorderPainter(), paints ..path( style: PaintingStyle.stroke, - ) + ), ); }); @@ -840,7 +865,7 @@ void main() { expect(findBorderPainter(), paints ..path( style: PaintingStyle.stroke, - ) + ), ); }); @@ -896,7 +921,7 @@ void main() { expect(findBorderPainter(), paints ..path( style: PaintingStyle.stroke, - ) + ), ); }); @@ -969,7 +994,7 @@ void main() { expect(findBorderPainter(), paints ..path( style: PaintingStyle.stroke, - ) + ), ); });