loadLadderFixtures function
Loads ladder fixture files from dir, returning sorted tier entries.
Each entry is a record of (tierName, fixtures) where fixtures is the
decoded JSON list from that tier file.
Implementation
List<(String, List<Map<String, dynamic>>)> loadLadderFixtures(Directory dir) {
final tierFiles = dir
.listSync()
.whereType<File>()
.where((f) => f.path.endsWith('.json'))
.toList()
..sort((a, b) => a.path.compareTo(b.path));
return [
for (final file in tierFiles)
(
file.uri.pathSegments.last.replaceAll('.json', ''),
(jsonDecode(file.readAsStringSync()) as List)
.cast<Map<String, dynamic>>(),
),
];
}