visibleWidgetIdSummary method

String visibleWidgetIdSummary({
  1. int limit = 20,
})

Implementation

String visibleWidgetIdSummary({int limit = 20}) {
  final ids = tester.allWidgets
      .map((widget) => widget.key)
      .whereType<ValueKey>()
      .map((key) => key.value.toString())
      .where((value) => value.isNotEmpty)
      .toSet()
      .toList()
    ..sort();
  if (ids.isEmpty) return 'No keyed test widgets are currently visible.';
  final shown = ids.take(limit).join(', ');
  final suffix = ids.length > limit ? ', ... (${ids.length} total)' : '';
  return 'Visible widget ids: $shown$suffix.';
}