Unverified Commit 0fbc95df authored by Tong Mu's avatar Tong Mu Committed by GitHub

Remove the extra wrapping of `Listener` (#67340)

parent 76cbc462
...@@ -5804,7 +5804,7 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget { ...@@ -5804,7 +5804,7 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget {
/// } /// }
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
class Listener extends StatelessWidget { class Listener extends SingleChildRenderObjectWidget {
/// Creates a widget that forwards point events to callbacks. /// Creates a widget that forwards point events to callbacks.
/// ///
/// The [behavior] argument defaults to [HitTestBehavior.deferToChild]. /// The [behavior] argument defaults to [HitTestBehavior.deferToChild].
...@@ -5819,8 +5819,7 @@ class Listener extends StatelessWidget { ...@@ -5819,8 +5819,7 @@ class Listener extends StatelessWidget {
this.behavior = HitTestBehavior.deferToChild, this.behavior = HitTestBehavior.deferToChild,
Widget? child, Widget? child,
}) : assert(behavior != null), }) : assert(behavior != null),
_child = child, super(key: key, child: child);
super(key: key);
/// Called when a pointer comes into contact with the screen (for touch /// Called when a pointer comes into contact with the screen (for touch
/// pointers), or has its button pressed (for mouse pointers) at this widget's /// pointers), or has its button pressed (for mouse pointers) at this widget's
...@@ -5856,52 +5855,6 @@ class Listener extends StatelessWidget { ...@@ -5856,52 +5855,6 @@ class Listener extends StatelessWidget {
/// How to behave during hit testing. /// How to behave during hit testing.
final HitTestBehavior behavior; final HitTestBehavior behavior;
// The widget listened to by the listener.
//
// The reason why we don't expose it is that once the deprecated methods are
// removed, Listener will no longer need to store the child, but will pass
// the child to `super` instead.
final Widget? _child;
@override
Widget build(BuildContext context) {
// TODO(dkwingsmt): Remove the extra wrapper, and make `Listener` a
// StatelessWidget. https://github.com/flutter/flutter/issues/65586
return _PointerListener(
onPointerDown: onPointerDown,
onPointerUp: onPointerUp,
onPointerMove: onPointerMove,
onPointerHover: onPointerHover,
onPointerCancel: onPointerCancel,
onPointerSignal: onPointerSignal,
behavior: behavior,
child: _child,
);
}
}
class _PointerListener extends SingleChildRenderObjectWidget {
const _PointerListener({
Key? key,
this.onPointerDown,
this.onPointerMove,
this.onPointerUp,
this.onPointerHover,
this.onPointerCancel,
this.onPointerSignal,
this.behavior = HitTestBehavior.deferToChild,
Widget? child,
}) : assert(behavior != null),
super(key: key, child: child);
final PointerDownEventListener? onPointerDown;
final PointerMoveEventListener? onPointerMove;
final PointerUpEventListener? onPointerUp;
final PointerHoverEventListener? onPointerHover;
final PointerCancelEventListener? onPointerCancel;
final PointerSignalEventListener? onPointerSignal;
final HitTestBehavior behavior;
@override @override
RenderPointerListener createRenderObject(BuildContext context) { RenderPointerListener createRenderObject(BuildContext context) {
return RenderPointerListener( return RenderPointerListener(
......
...@@ -157,7 +157,6 @@ void main() { ...@@ -157,7 +157,6 @@ void main() {
' Semantics\n' ' Semantics\n'
' FocusScope\n' ' FocusScope\n'
' AbsorbPointer\n' ' AbsorbPointer\n'
' _PointerListener\n'
' Listener\n' ' Listener\n'
' HeroControllerScope\n' ' HeroControllerScope\n'
' Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#00000]\n' ' Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#00000]\n'
......
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