checkForScroll method

Future<void> checkForScroll()

Implementation

Future<void> checkForScroll() async {
  if (scrollCapture != null) {
    final _Swipe swipe = scrollCapture!;

    scrollCapture = null;

    if (swipe.getUpdatePosition != null && swipe.velocity != null) {
      final Offset? start = swipe.getStartPosition;
      final Offset? end = swipe.getUpdatePosition;
      final Velocity? velocity = swipe.velocity;
      final String direction = swipe.direction;

      tlLogger.t(
        'Scrollable start timestamp: ${swipe.getStartTimestampString()}',
      );
      tlLogger.t(
        'Scrollable, start: ${start?.dx},${start?.dy}, end: ${end?.dx},${end?.dy}, velocity: $velocity, direction: $direction',
      );

      logWidgetTree()
          .then((result) async {
            // TODO: missing context?
            // var touchedTarget = findTouchedWidget(context, details.position);

            if (ConnectHelper.captureScreen) {
              await PluginConnect.onTlGestureEvent(
                gesture: 'swipe',
                id: '../Scrollable',
                target: 'Scrollable',
                data: <String, dynamic>{
                  'pointer1': {
                    'dx': start?.dx,
                    'dy': start?.dy,
                    'ts': swipe.getStartTimestampString(),
                  },
                  'pointer2': {
                    'dx': end?.dx,
                    'dy': end?.dy,
                    'ts': swipe.getUpdateTimestampString(),
                  },
                  'velocity': {
                    'dx': velocity?.pixelsPerSecond.dx,
                    'dy': velocity?.pixelsPerSecond.dy,
                  },
                  'direction': direction,
                },
                layoutParameters: result,
              );
            }
          })
          .catchError((error) {
            // Handle errors if the async function throws an error
            tlLogger.e('Error: $error');
          });

      // For Cancelling the pointerUp event
      Connect.isSwiping = false;
    } else {
      tlLogger.t('Incomplete scroll before frame');
    }
  }
}