RawGestureDetector class
A widget that detects gestures described by the given gesture factories.
For common gestures, use a GestureDetector. RawGestureDetector is useful primarily when developing your own gesture recognizers.
Configuring the gesture recognizers requires a carefully constructed map, as described in gestures and as shown in the example below.
This example shows how to hook up a TapGestureRecognizer. It assumes that
the code is being used inside a State object with a
link
_last
field that is
then displayed as the child of the gesture detector.
RawGestureDetector(
gestures: <Type, GestureRecognizerFactory>{
TapGestureRecognizer: GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
() => TapGestureRecognizer(),
(TapGestureRecognizer instance) {
instance
..onTapDown = (TapDownDetails details) { setState(() { _last = 'down'; }); }
..onTapUp = (TapUpDetails details) { setState(() { _last = 'up'; }); }
..onTap = () { setState(() { _last = 'tap'; }); }
..onTapCancel = () { setState(() { _last = 'cancel'; }); };
},
),
},
child: Container(width: 300.0, height: 300.0, color: Colors.yellow, child: Text(_last)),
)
See also:
- GestureDetector, a less flexible but much simpler widget that does the same thing.
- Listener, a widget that reports raw pointer events.
- GestureRecognizer, the class that you extend to create a custom gesture recognizer.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- RawGestureDetector
Constructors
-
RawGestureDetector({Key? key, Widget? child, Map<
Type, GestureRecognizerFactory< gestures = const <Type, GestureRecognizerFactory>{}, HitTestBehavior? behavior, bool excludeFromSemantics = false, SemanticsGestureDelegate? semantics})GestureRecognizer> > -
Creates a widget that detects gestures.
const
Properties
- behavior → HitTestBehavior?
-
How this gesture detector should behave during hit testing.
final
- child → Widget?
-
The widget below this widget in the tree.
final
- excludeFromSemantics → bool
-
Whether to exclude these gestures from the semantics tree. For
example, the long-press gesture for showing a tooltip is
excluded because the tooltip itself is included in the semantics
tree directly and so having a gesture to show it would result in
duplication of information.
final
-
gestures
→ Map<
Type, GestureRecognizerFactory< GestureRecognizer> > -
The gestures that this widget will attempt to recognize.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semantics → SemanticsGestureDelegate?
-
Describes the semantics notations that should be added to the underlying
render object RenderSemanticsGestureHandler.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → RawGestureDetectorState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited