mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Material] Remove "down position" from toggleable ripple calculation (#112209)
* remove down position from toggleable ripple
This commit is contained in:
parent
4beceb8f5f
commit
96a770bda0
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user