diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index aa1565ac5c..4b6b076385 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -1071,7 +1071,10 @@ class _InkResponseState extends State<_InkResponseStateWidget> for (final _HighlightType type in _highlights.keys) { _highlights[type]?.color = getHighlightColorForType(type); } - _currentSplash?.color = widget.splashColor ?? Theme.of(context).splashColor; + + const Set pressed = {MaterialState.pressed}; + _currentSplash?.color = widget.overlayColor?.resolve(pressed) ?? widget.splashColor ?? Theme.of(context).splashColor; + final MouseCursor effectiveMouseCursor = MaterialStateProperty.resolveAs( widget.mouseCursor ?? MaterialStateMouseCursor.clickable, { diff --git a/packages/flutter/test/material/elevated_button_test.dart b/packages/flutter/test/material/elevated_button_test.dart index 6572e60547..7d7710970a 100644 --- a/packages/flutter/test/material/elevated_button_test.dart +++ b/packages/flutter/test/material/elevated_button_test.dart @@ -50,8 +50,11 @@ void main() { expect(material.type, MaterialType.button); final Offset center = tester.getCenter(find.byType(ElevatedButton)); - await tester.startGesture(center); - await tester.pumpAndSettle(); + final TestGesture gesture = await tester.startGesture(center); + await tester.pump(); // start the splash animation + await tester.pump(const Duration(milliseconds: 100)); // splash is underway + final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); + expect(inkFeatures, paints..circle(color: colorScheme.onPrimary.withAlpha(0x3d))); // splash color is onPrimary(0.24) // Only elevation changes when enabled and pressed. material = tester.widget(rawButtonMaterial); @@ -69,6 +72,9 @@ void main() { expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.type, MaterialType.button); + await gesture.up(); + await tester.pumpAndSettle(); + // Disabled ElevatedButton await tester.pumpWidget( MaterialApp( diff --git a/packages/flutter/test/material/outlined_button_test.dart b/packages/flutter/test/material/outlined_button_test.dart index c63e8bd4cc..80be500701 100644 --- a/packages/flutter/test/material/outlined_button_test.dart +++ b/packages/flutter/test/material/outlined_button_test.dart @@ -56,9 +56,14 @@ void main() { expect(material.type, MaterialType.button); final Offset center = tester.getCenter(find.byType(OutlinedButton)); - await tester.startGesture(center); - await tester.pumpAndSettle(); + final TestGesture gesture = await tester.startGesture(center); + await tester.pump(); // start the splash animation + await tester.pump(const Duration(milliseconds: 100)); // splash is underway + final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); + expect(inkFeatures, paints..circle(color: colorScheme.primary.withAlpha(0x1f))); // splash color is primary(0.12) + await gesture.up(); + await tester.pumpAndSettle(); // No change vs enabled and not pressed. material = tester.widget(rawButtonMaterial); expect(material.animationDuration, const Duration(milliseconds: 200)); diff --git a/packages/flutter/test/material/text_button_test.dart b/packages/flutter/test/material/text_button_test.dart index 76e78971bd..ab4a97bc29 100644 --- a/packages/flutter/test/material/text_button_test.dart +++ b/packages/flutter/test/material/text_button_test.dart @@ -50,9 +50,14 @@ void main() { expect(material.type, MaterialType.button); final Offset center = tester.getCenter(find.byType(TextButton)); - await tester.startGesture(center); - await tester.pumpAndSettle(); + final TestGesture gesture = await tester.startGesture(center); + await tester.pump(); // start the splash animation + await tester.pump(const Duration(milliseconds: 100)); // splash is underway + final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); + expect(inkFeatures, paints..circle(color: colorScheme.primary.withAlpha(0x1f))); // splash color is primary(0.12) + await gesture.up(); + await tester.pumpAndSettle(); material = tester.widget(buttonMaterial); // No change vs enabled and not pressed. expect(material.animationDuration, const Duration(milliseconds: 200)); @@ -969,6 +974,7 @@ void main() { ); expect(paddingWidget.padding, const EdgeInsets.all(22)); }); + }