planInteractions method

List<PlannedInteraction> planInteractions(
  1. Map<String, dynamic> widgetTree
)

Implementation

List<PlannedInteraction> planInteractions(Map<String, dynamic> widgetTree) {
  final tappables = <Map<String, dynamic>>[];
  final scrollables = <Map<String, dynamic>>[];
  final textFields = <Map<String, dynamic>>[];
  final animated = <Map<String, dynamic>>[];

  _collectInteractables(
      widgetTree, tappables, scrollables, textFields, animated);

  final planned = <PlannedInteraction>[];

  for (final widget in tappables) {
    final interaction = _classifyTappable(widget);
    if (interaction != null) planned.add(interaction);
  }

  for (final widget in scrollables) {
    planned.add(PlannedInteraction(
      widgetType: widget['widgetRuntimeType'] ?? 'ScrollView',
      type: InteractionType.scroll,
      reason: 'Measure scroll performance',
      file: widget['creationLocation']?['file']?.toString().split('/').last,
      line: widget['creationLocation']?['line'] as int?,
    ));
  }

  for (final widget in textFields) {
    final key = widget['key']?.toString() ?? '';
    planned.add(PlannedInteraction(
      widgetType: 'TextField',
      type: InteractionType.typeText,
      reason: 'Test text input performance',
      widgetKey: key,
      testData: _getTestData(key),
      file: widget['creationLocation']?['file']?.toString().split('/').last,
      line: widget['creationLocation']?['line'] as int?,
    ));
  }

  for (final widget in animated) {
    planned.add(PlannedInteraction(
      widgetType: widget['widgetRuntimeType'] ?? 'AnimatedWidget',
      type: InteractionType.animate,
      reason: 'Measure animation frame rate',
      file: widget['creationLocation']?['file']?.toString().split('/').last,
      line: widget['creationLocation']?['line'] as int?,
    ));
  }

  return planned;
}