generateHtmlFormattedDiff function
Generates an HTML diff between two XML strings using the DiffMatchPatch package with color-coded formatting (additions in green, deletions in red)
Implementation
String generateHtmlFormattedDiff(
String actual,
String expected, {
String title = 'String Comparison',
String subtitle = 'Diff report between two strings',
}) {
// Create a new DiffMatchPatch instance
final diffMatchPatch = dmp.DiffMatchPatch();
// Generate diffs between the two XML strings
final diffs = diffMatchPatch.diff(actual, expected);
diffMatchPatch.diffCleanupEfficiency(diffs);
diffMatchPatch.diffCleanupSemantic(diffs);
// Convert the diffs to HTML with proper styling
return diffsToHtml(diffs, title: title, subtitle: subtitle);
}