[Material] Remove "down position" from toggleable ripple calculation (#112209)
* remove down position from toggleable ripple
diff --git a/packages/flutter/lib/src/material/toggleable.dart b/packages/flutter/lib/src/material/toggleable.dart
index 211d820..9fc0bb4 100644
--- a/packages/flutter/lib/src/material/toggleable.dart
+++ b/packages/flutter/lib/src/material/toggleable.dart
@@ -559,7 +559,6 @@
focusColor,
reactionFocusFade.value,
)!;
- final Offset center = Offset.lerp(downPosition ?? origin, origin, reaction.value)!;
final Animatable<double> radialReactionRadiusTween = Tween<double>(
begin: 0.0,
end: splashRadius,
@@ -568,7 +567,7 @@
? splashRadius
: radialReactionRadiusTween.evaluate(reaction);
if (reactionRadius > 0.0) {
- canvas.drawCircle(center + offset, reactionRadius, reactionPaint);
+ canvas.drawCircle(origin + offset, reactionRadius, reactionPaint);
}
}
}
diff --git a/packages/flutter/test/material/checkbox_test.dart b/packages/flutter/test/material/checkbox_test.dart
index 3967ab8..7230c0d 100644
--- a/packages/flutter/test/material/checkbox_test.dart
+++ b/packages/flutter/test/material/checkbox_test.dart
@@ -602,6 +602,38 @@
);
});
+ testWidgets('Checkbox starts the splash in center, even when tap is on the corner', (WidgetTester tester) async {
+ Widget buildApp() {
+ return MaterialApp(
+ theme: theme,
+ home: Material(
+ child: Center(
+ child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
+ return Checkbox(
+ value: false,
+ onChanged: (bool? newValue) {},
+ );
+ }),
+ ),
+ ),
+ );
+ }
+
+ await tester.pumpWidget(buildApp());
+ final Offset checkboxTopLeftGlobal = tester.getTopLeft(find.byType(Checkbox));
+ final Offset checkboxCenterGlobal = tester.getCenter(find.byType(Checkbox));
+ final Offset checkboxCenterLocal = checkboxCenterGlobal - checkboxTopLeftGlobal;
+ await tester.startGesture(checkboxTopLeftGlobal);
+ await tester.pump();
+ // Wait for the splash to be drawn, but not long enough for it to animate towards the center, since
+ // we want to catch it in its starting position.
+ await tester.pump(const Duration(milliseconds: 1));
+ expect(
+ Material.of(tester.element(find.byType(Checkbox))),
+ paints..circle(x: checkboxCenterLocal.dx, y: checkboxCenterLocal.dy),
+ );
+ });
+
testWidgets('Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true;