Я фильтрую свой список моего GridView.builder следующим образом:
onSearchTextChanged(String text) async {
if (text.isEmpty) {
_searchList = _productList.toList();
setState(() {
});
return;
}
_searchList = _productList.where((product) => product.name.toLowerCase().contains(text.toLowerCase()) ||
product.type.toLowerCase().contains(text.toLowerCase())).toList();
setState(() {});
}
, но когда я набираю текстовое поле, производительность просто падает, ровно до 2,5 кадров в секунду.иногда, когда я удаляю текст или быстро набираю текст.
Это мой конструктор Gridview
GridView.builder(
primary: false,
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: itemWidth / itemHeight,
),
itemCount: _searchList.length,
itemBuilder: (BuildContext context, int index) {
return _searchList[index];
}));