@@ -40,6 +40,7 @@ class Filters extends StatefulComponent {
4040 required this .data,
4141 required this .items,
4242 required this .filters,
43+ this .showInitialCount = 9 ,
4344 this .scope = '' ,
4445 this .emptyResultsMessage = 'No results match these filters.' ,
4546 this .emptyDataMessage = 'No results are available.' ,
@@ -50,6 +51,7 @@ class Filters extends StatefulComponent {
5051 final List <Map <String , Object ?>> data;
5152 final List <Component > items;
5253 final List <FilterType > filters;
54+ final int showInitialCount;
5355
5456 /// Prefix applied to the URL parameters and element IDs this component owns.
5557 ///
@@ -67,7 +69,7 @@ class Filters extends StatefulComponent {
6769}
6870
6971class _FiltersState extends State <Filters > {
70- int _showItemsCount = 9 ;
72+ late int _showItemsCount;
7173 Map <FilterType , Set <String >> _activeFilters = {};
7274
7375 /// Indexes into [Filters.items] of the items matching [_activeFilters] ,
@@ -84,6 +86,8 @@ class _FiltersState extends State<Filters> {
8486 @override
8587 void initState () {
8688 super .initState ();
89+ assert (component.showInitialCount > 0 , 'showInitialCount must be greater than 0' );
90+ _showItemsCount = component.showInitialCount;
8791 _matchingIndexes = [
8892 for (var index = 0 ; index < component.items.length; index++ ) index,
8993 ];
@@ -212,7 +216,7 @@ class _FiltersState extends State<Filters> {
212216 classes: 'btn' ,
213217 onClick: () {
214218 setState (() {
215- _showItemsCount += 9 ;
219+ _showItemsCount += component.showInitialCount ;
216220 });
217221 },
218222 const [.text ('Load more' )],
0 commit comments