Unverified Commit e02462a4 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

`CheckedPopupMenuItem`: Fix cursor bug and add cursor parameter (#103474)

parent a27fcf1a
...@@ -461,6 +461,7 @@ class CheckedPopupMenuItem<T> extends PopupMenuItem<T> { ...@@ -461,6 +461,7 @@ class CheckedPopupMenuItem<T> extends PopupMenuItem<T> {
super.enabled, super.enabled,
super.padding, super.padding,
super.height, super.height,
super.mouseCursor,
super.child, super.child,
}) : assert(checked != null); }) : assert(checked != null);
...@@ -514,13 +515,15 @@ class _CheckedPopupMenuItemState<T> extends PopupMenuItemState<T, CheckedPopupMe ...@@ -514,13 +515,15 @@ class _CheckedPopupMenuItemState<T> extends PopupMenuItemState<T, CheckedPopupMe
@override @override
Widget buildChild() { Widget buildChild() {
return ListTile( return IgnorePointer(
child: ListTile(
enabled: widget.enabled, enabled: widget.enabled,
leading: FadeTransition( leading: FadeTransition(
opacity: _opacity, opacity: _opacity,
child: Icon(_controller.isDismissed ? null : Icons.done), child: Icon(_controller.isDismissed ? null : Icons.done),
), ),
title: widget.child, title: widget.child,
),
); );
} }
} }
......
...@@ -1620,7 +1620,6 @@ void main() { ...@@ -1620,7 +1620,6 @@ void main() {
); );
}); });
testWidgets('CheckedPopupMenuItem custom padding', (WidgetTester tester) async { testWidgets('CheckedPopupMenuItem custom padding', (WidgetTester tester) async {
final Key popupMenuButtonKey = UniqueKey(); final Key popupMenuButtonKey = UniqueKey();
final Type menuItemType = const CheckedPopupMenuItem<String>(child: Text('item')).runtimeType; final Type menuItemType = const CheckedPopupMenuItem<String>(child: Text('item')).runtimeType;
...@@ -2092,6 +2091,86 @@ void main() { ...@@ -2092,6 +2091,86 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
}); });
testWidgets('CheckedPopupMenuItem changes mouse cursor when hovered', (WidgetTester tester) async {
const Key key = ValueKey<int>(1);
// Test CheckedPopupMenuItem() constructor
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: Material(
child: MouseRegion(
cursor: SystemMouseCursors.forbidden,
child: CheckedPopupMenuItem<int>(
key: key,
mouseCursor: SystemMouseCursors.text,
value: 1,
child: Container(),
),
),
),
),
),
),
);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1);
await gesture.addPointer(location: tester.getCenter(find.byKey(key)));
addTearDown(gesture.removePointer);
await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: Material(
child: MouseRegion(
cursor: SystemMouseCursors.forbidden,
child: CheckedPopupMenuItem<int>(
key: key,
value: 1,
child: Container(),
),
),
),
),
),
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: Material(
child: MouseRegion(
cursor: SystemMouseCursors.forbidden,
child: CheckedPopupMenuItem<int>(
key: key,
value: 1,
enabled: false,
child: Container(),
),
),
),
),
),
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
});
testWidgets('PopupMenu in AppBar does not overlap with the status bar', (WidgetTester tester) async { testWidgets('PopupMenu in AppBar does not overlap with the status bar', (WidgetTester tester) async {
const List<PopupMenuItem<int>> choices = <PopupMenuItem<int>>[ const List<PopupMenuItem<int>> choices = <PopupMenuItem<int>>[
PopupMenuItem<int>(value: 1, child: Text('Item 1')), PopupMenuItem<int>(value: 1, child: Text('Item 1')),
......
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