Skip to content

Commit

Permalink
Fix sample generator
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpryan committed Feb 27, 2025
1 parent f93fb5d commit 91542a3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkgs/samples/tool/samples.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,19 @@ abstract final class Samples {
}

String _mapForCategory(String category) {
final items = samples.where((s) => s.category == category);
return ''''$category': [
${items.map((i) => i.sourceId).join(',\n ')},
]''';
final items = samples.where((s) => s.category == category).toList();
final buffer = StringBuffer();
buffer.write("'$category': [");
//Put a comma between each item, but not after the last item
for (var i = 0; i < items.length; i++) {
buffer.write(items[i].sourceId);
if (i < items.length - 1) {
buffer.write(', ');
}
}
buffer.write(']');

return buffer.toString();
}
}

Expand Down

0 comments on commit 91542a3

Please sign in to comment.