handle static method

Future<void> handle({
  1. required String action,
  2. required String targetText,
  3. required String actionId,
  4. RenderRepaintBoundary? renderRepaintBoundary,
  5. Offset? offset,
  6. Size? size,
})

操作ログをハンドルします。

操作ログはペアリング時のみ送信されます。 イベント発火条件定義に操作ログがマッチした際にビジュアルイベントが送信されます。

action にアクション名を指定します。 targetText にターゲット文字列を指定します。(Viewコンポーネントのタイトルなど) actionId アクションIDを指定します。(アクションIDにはアプリ再起動時も変化しない一意なIDを設定してください。) renderRepaintBoundary 画像データの取得元となるRenderRepaintBoundary。(ペアリング時の操作ログ送信でのみ利用されます。) offset RenderRepaintBoundaryと操作ログ対象Widgetの相対座標 size 操作ログ対象Widgetのサイズ

Implementation

static Future<void> handle(
    {required String action,
    required String targetText,
    required String actionId,
    RenderRepaintBoundary? renderRepaintBoundary,
    Offset? offset,
    Size? size}) async {
  var imageData;

  final isPaired = await _channel.invokeMethod('VisualTracking_isPaired');
  if (isPaired) {
    imageData = await _imageData(renderRepaintBoundary);
  }

  final offsetX = offset != null ? _pixelRatio * offset.dx : null;
  final offsetY = offset != null ? _pixelRatio * offset.dy : null;
  final imageWidth = size != null ? _pixelRatio * size.width : null;
  final imageHeight = size != null ? _pixelRatio * size.height : null;
  await _channel.invokeMethod('VisualTracking_handle', {
    "action": action,
    "targetText": targetText,
    "actionId": actionId,
    "imageData": imageData,
    "offsetX": offsetX,
    "offsetY": offsetY,
    "imageWidth": imageWidth,
    "imageHeight": imageHeight,
  });
}