ExportedIDLookup class
Used to look up what part of a ScalableImage is clicked on within a ScalableImageWidget.
An SVG node can have a name in its id
attribute. When an SVG is read,
or converted to an SI, these ID values can be marked as exported. This can
be done by listing the IDs, or by using a regular expression. For example,
to build an SI where all ID values are exported, you can specify
-x '.*'
to svg_to_si
. Each exported ID does add some overhead, so
in production, it's best to only export the ones you need.
A ScalableImageWidget can have an ExportedIDLookup instance associated with it. This can be used, for example, to determine which node(s) are under a mouse click (or other tap event).
Usage:
class _GlorpState extends State<GlorpWidget> {
final ExportedIDLookup _idLookup = ExportedIDLookup();
...
@override
Widget build() => ...
GestureDetector(
onTapDown: _handleTapDown,
child: ScalableImageWidget(
...
lookup: _idLookup))
...;
void _handleTapDown(TapDownDetails event) {
final Set<String> hits = _idLookup.hits(event.localPosition);
print('Tap down at ${event.localPosition}: $hits');
}
}
See example/lib/animation.dart
and demo/lib/main.dart
for
more complete examples.
Constructors
Properties
-
exportedIDs
→ Set<
ExportedID> -
Get the exported IDs from the underlying ScalableImage instance, if
it has been loaded. The ExportedIDs will be in the coordinate system
of the ScalableImage. See also scalingTransform.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scalingTransform → ScalingTransform
-
Get the ScalingTransform needed to convert coordinates between the
coordinate system of the ScalableImage's exportedIDs and the
containing ScalableImageWidget.
no setter
Methods
-
hits(
Offset p) → Set< String> -
Return the set of node IDs whose bounding rectangles contain
p
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited