Unverified Commit 96a770bd authored by MH Johnson's avatar MH Johnson Committed by GitHub

[Material] Remove "down position" from toggleable ripple calculation (#112209)

* remove down position from toggleable ripple
parent 4beceb8f
......@@ -559,7 +559,6 @@ abstract class ToggleablePainter extends ChangeNotifier implements CustomPainter
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 @@ abstract class ToggleablePainter extends ChangeNotifier implements CustomPainter
? splashRadius
: radialReactionRadiusTween.evaluate(reaction);
if (reactionRadius > 0.0) {
canvas.drawCircle(center + offset, reactionRadius, reactionPaint);
canvas.drawCircle(origin + offset, reactionRadius, reactionPaint);
}
}
}
......
......@@ -602,6 +602,38 @@ void main() {
);
});
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment