“_buildCategoryList”需要2个位置参数,但找到了1个。
尝试添加缺少的参数
Widget _categoriesList(WidgetRef ref) {
final categories = ref.watch(
categoriesProvider(
PaginationModel(page: 1, pageSize: 10),
),
);
return categories.when(
data: (list) {
return _buildCategoryList(list!.cast<Category>());
},
error: (_, __) => const Center(
child: Text("ERR"),
),
loading: () => const Center(
child: CircularProgressIndicator(),
));
}
Widget _buildCategoryList(List<Category> categories, WidgetRef ref) {
return Container(
child: ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: categories.length,
itemBuilder: (context, index) {
var data = categories[index];
return GestureDetector(
onTap: () {
ProductFilterModel filterModel = ProductFilterModel(
paginationModel: PaginationModel(page: 1, pageSize: 10),
categoryId: data.categoryId);
ref
.read(productsFilterProvider.notifier)
.setProductFilter(filterModel);
ref.read(productsNotifierProvider.notifier).getProducts();
Navigator.of(context).pushNamed("/products", arguments: {
'categoryId': data.categoryId,
'categoryName': data.categoryName,
});
},
1条答案
按热度按时间hmae6n7t1#
由于
_buildCategoryList
小部件有两个参数,但您只传递了一个参数。