mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove the extra wrapping of Listener (#67340)
This commit is contained in:
parent
76cbc462d2
commit
0fbc95df21
@ -5804,7 +5804,7 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget {
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
class Listener extends StatelessWidget {
|
||||
class Listener extends SingleChildRenderObjectWidget {
|
||||
/// Creates a widget that forwards point events to callbacks.
|
||||
///
|
||||
/// The [behavior] argument defaults to [HitTestBehavior.deferToChild].
|
||||
@ -5819,8 +5819,7 @@ class Listener extends StatelessWidget {
|
||||
this.behavior = HitTestBehavior.deferToChild,
|
||||
Widget? child,
|
||||
}) : assert(behavior != null),
|
||||
_child = child,
|
||||
super(key: key);
|
||||
super(key: key, child: child);
|
||||
|
||||
/// 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
|
||||
@ -5856,52 +5855,6 @@ class Listener extends StatelessWidget {
|
||||
/// How to behave during hit testing.
|
||||
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
|
||||
RenderPointerListener createRenderObject(BuildContext context) {
|
||||
return RenderPointerListener(
|
||||
|
||||
@ -157,7 +157,6 @@ void main() {
|
||||
' Semantics\n'
|
||||
' FocusScope\n'
|
||||
' AbsorbPointer\n'
|
||||
' _PointerListener\n'
|
||||
' Listener\n'
|
||||
' HeroControllerScope\n'
|
||||
' Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#00000]\n'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user