onTlGestureEvent static method

Future<void> onTlGestureEvent({
  1. required String? gesture,
  2. required String id,
  3. required String target,
  4. Map<String, dynamic>? data,
  5. List<Map<String, dynamic>>? layoutParameters,
})

Handles incoming gesture events from the Flutter engine.

gesture: The type of gesture, e.g., 'pinch', 'swipe', 'taphold', 'doubletap', or 'tap'. id: The unique identifier of the gesture event. target: The target of the gesture event, e.g., a widget ID. data: Additional data associated with the gesture event, if any. layoutParameters: Layout parameters associated with the gesture event, if any.

Throws a TealeafException if the gesture type is not supported or if there is an error processing the gesture message.

Implementation

static Future<void> onTlGestureEvent(
    {required String? gesture,
    required String id,
    required String target,
    Map<String, dynamic>? data,
    List<Map<String, dynamic>>? layoutParameters}) async {
  try {
    if (["pinch", "swipe", "taphold", "doubletap", "tap"].contains(gesture)) {
      return await _channel.invokeMethod('gesture', <dynamic, dynamic>{
        'tlType': gesture,
        'id': id,
        'target': target,
        'data': data,
        'layoutParameters': layoutParameters ?? <Map<String, dynamic>>[]
      });
    }
    throw TealeafException.create(
        code: 3, msg: 'Illegal gesture type: "$gesture"');
  } on PlatformException catch (pe) {
    throw TealeafException(pe, msg: 'Unable to process gesture message!');
  }
}