Skip to content

Commit 0fac8c1

Browse files
committed
Implement sorting
1 parent 81f4285 commit 0fac8c1

File tree

2 files changed

+3001
-2991
lines changed

2 files changed

+3001
-2991
lines changed

dev/tools/update_icons.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ Map<String, String> stringToTokenPairMap(String codepointData) {
243243
}
244244

245245
String regenerateIconsFile(String iconData, Map<String, String> tokenPairMap) {
246-
final Iterable<_Icon> newIcons = tokenPairMap.entries.map((MapEntry<String, String> entry) => _Icon(entry));
246+
final List<_Icon> newIcons = tokenPairMap.entries.map((MapEntry<String, String> entry) => _Icon(entry)).toList();
247+
newIcons.sort((_Icon a, _Icon b) => a.compareTo(b));
248+
247249
final StringBuffer buf = StringBuffer();
248250
bool generating = false;
249251

@@ -413,6 +415,14 @@ class _Icon {
413415
IconData get $fullFlutterId => !_isCupertino() ? Icons.${agnosticIcon.fullFlutterId} : Icons.${iOSIcon.fullFlutterId};
414416
''';
415417

418+
/// Analogous to [String.compareTo]
419+
int compareTo(_Icon b) {
420+
// Sort regular icons before their variants.
421+
if (flutterId == b.flutterId && style == IconStyle.regular)
422+
return -1;
423+
return flutterId.compareTo(b.flutterId);
424+
}
425+
416426
@override
417427
String toString() => id;
418428
}

0 commit comments

Comments
 (0)