Flutter widget AbsorbPointer

 When absorbing is true, this widget prevents its subtree from receiving pointer events by terminating hit testing at itself. It still consumes space during layout and paints its child as usual. It just prevents its children from being the target of located events, because it returns true from RenderBox.hitTest.

Constructors

AbsorbPointer({Key keybool absorbingtrueWidget childbool ignoringSemantics})
Creates a widget that absorbs pointers during hit testing. [...]
const

Properties

absorbing → bool
Whether this widget absorbs pointers during hit testing.

Using AbsorbPointer

Below is the constructor of AbsorbPointer along with its properties:

const AbsorbPointer({
Key key,
this.absorbing = true,
Widget child,
this.ignoringSemantics,
})

Properties:

  • Key key: The widget key, used to control if it's should be replaced.
  • bool absorbing: Whether this widget absorbs pointers during hit testing. Defaults to true.
  • bool ignoringSemantics: Whether the semantics of this widget is ignored when compiling the semantics tree.
  • Widget child: The widget to be rendered.

If absorbing value is true, any click inside the widget will be absorbed. If you don't pass absorbing parameter, it will use the default value (true) which causes any pointer inside the widget will be absorbed.

The usage of AbsorbPointer is similar to IgnorePointer, just change ignoring property with absorbing.

IgnorePointer(
ignoring: _ignoring,
child: MyWidget(),
)
Flutter widget AbsorbPointer Flutter widget AbsorbPointer Reviewed by Admin on 5:02 AM Rating: 5

No comments:

Powered by Blogger.