apply method
Apply the rule to the analysis result Returns a list of widgets in their recommended order
Implementation
@override
List<String> apply(Map<String, int> interactionCounts) {
if (interactionCounts.isEmpty) return [];
// Calculate mean interaction count
final values = interactionCounts.values.toList();
final mean =
values.fold<int>(0, (sum, count) => sum + count) / values.length;
// Get widgets with counts above the threshold
final outliers = interactionCounts.entries
.where((entry) => entry.value > mean * threshold)
.map((e) => e.key)
.toList();
// Get the rest of the widgets
final rest = interactionCounts.entries
.where((entry) => !outliers.contains(entry.key))
.map((e) => e.key)
.toList();
// Return outliers first, then the rest
return [...outliers, ...rest];
}