Unverified Commit 95116386 authored by Gustav Bylund's avatar Gustav Bylund Committed by GitHub

Replace ListView with ListView.builder for LicensesPage (#102692)

parent 6504f289
......@@ -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),
));
},
);
},
);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment