Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ListView with ListView.builder for LicensesPage #102692

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions packages/flutter/lib/src/material/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -607,31 +607,29 @@ class _PackagesViewState extends State<_PackagesView> {
final _LicenseData data,
final bool drawSelection,
) {
return ListView(
children: <Widget>[
widget.about,
...data.packages
.asMap()
.entries
.map<Widget>((MapEntry<int, String> entry) {
final String packageName = entry.value;
final int index = entry.key;
final List<int> bindings = data.packageLicenseBindings[packageName]!;
return _PackageListTile(
packageName: packageName,
index: index,
isSelected: drawSelection && entry.key == (selectedId ?? 0),
numberLicenses: bindings.length,
onTap: () {
widget.selectedId.value = index;
_MasterDetailFlow.of(context)!.openDetailPage(_DetailArguments(
packageName,
bindings.map((int i) => data.licenses[i]).toList(growable: false),
));
},
);
}),
],
return ListView.builder(
itemCount: data.packages.length + 1,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return widget.about;
}
final int packageIndex = index - 1;
final String packageName = data.packages[packageIndex];
final List<int> bindings = data.packageLicenseBindings[packageName]!;
return _PackageListTile(
packageName: packageName,
index: packageIndex,
isSelected: drawSelection && packageIndex == (selectedId ?? 0),
numberLicenses: bindings.length,
onTap: () {
widget.selectedId.value = packageIndex;
_MasterDetailFlow.of(context)!.openDetailPage(_DetailArguments(
packageName,
bindings.map((int i) => data.licenses[i]).toList(growable: false),
));
},
);
},
);
}
}
Expand Down