RawGestureDetectorModifier class
A widget that detects gestures described by the given gesture factories.
For common gestures, use a GestureRecognizer. 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.
{@tool snippet}
This example shows how to hook up a TapGestureRecognizer. It assumes that
the code is being used inside a State object with a _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)),
)
{@end-tool}
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
- StatelessWidget
- SingleChildStatelessModifier
- RawGestureDetectorModifier
- Available extensions
Constructors
-
RawGestureDetectorModifier({Key? key, Widget? child, Key? modifierKey, Map<
Type, GestureRecognizerFactory< gestures = const <Type, GestureRecognizerFactory>{}, HitTestBehavior? behavior, SemanticsGestureDelegate? semantics, bool excludeFromSemantics = false})GestureRecognizer> > -
Creates a widget that detects gestures.
const
Properties
- behavior → HitTestBehavior?
-
How this gesture detector should behave during hit testing.
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
- modifierKey → Key?
-
The actual key of the widget, which Modifier wrapped
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
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
buildWithChild(
BuildContext context, Widget? child) → Widget -
A build method that receives an extra
child
parameter.override -
createElement(
) → SingleChildStatelessElement -
Create a SingleChildStatelessElement
inherited
-
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
-
modified(
) → Modifier -
Available on Widget, provided by the ModifierTransformer extension
Transform normal widget to Modifier -
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