formatOptimizationResult method
Implementation
String formatOptimizationResult(List<OptimizationResult> results) {
final buffer = StringBuffer();
final totalSaved = results.fold(0, (sum, r) => sum + r.savedBytes);
final totalOriginal = results.fold(
0,
(sum, r) => sum + r.originalAsset.size,
);
// Header
buffer.writeln(Color.cyan('\n✨ Optimization Results'));
buffer.writeln(Color.dim('=' * _terminalWidth));
// Summary
buffer.writeln(
'\nOptimized ${Color.yellow(results.length.toString())} files');
buffer.writeln('Total space saved: ${Color.green(_formatSize(totalSaved))} '
'${Color.dim('(${(totalSaved / totalOriginal * 100).toStringAsFixed(1)}%)')}');
// Savings by type
_writeSavingsByType(buffer, results, totalSaved);
// Best optimizations
_writeBestOptimizations(buffer, results);
// Add recommendations if needed
_writeRecommendations(buffer, results);
return buffer.toString();
}