Skip to content

Commit 735fc29

Browse files
[flutter_tools] refactor license collector (#128748)
Improve debugging for flutter/flutter#128680 In the linked issue, I cannot explain how we are getting a type error. However, this refactor eliminates the null check operator (by iterating over `MapEntries` rather than the keys) in hopes that there will be a more descriptive error in the future. The correctness of this change is verified by the existing tests in https://github.com/flutter/flutter/blob/master/packages/flutter_tools/test/general.shard/license_collector_test.dart
1 parent f8e8d89 commit 735fc29

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/flutter_tools/lib/src/license_collector.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ class LicenseCollector {
8282
}
8383
}
8484

85-
final List<String> combinedLicensesList = packageLicenses.keys
86-
.map<String>((String license) {
87-
final List<String> packageNames = packageLicenses[license]!.toList()
88-
..sort();
89-
return '${packageNames.join('\n')}\n\n$license';
85+
final List<String> combinedLicensesList = packageLicenses.entries
86+
.map<String>((MapEntry<String, Set<String>> entry) {
87+
final List<String> packageNames = entry.value.toList()..sort();
88+
return '${packageNames.join('\n')}\n\n${entry.key}';
9089
}).toList();
9190
combinedLicensesList.sort();
9291

0 commit comments

Comments
 (0)