我是 flutter 新手,我不明白如何按降序或升序对 firebase 中的数据进行排序。这是代码。提前致谢。
Expanded(
child: Container(
width: size.width,
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
child: GridView.builder(
padding: const EdgeInsets.all(0),
// physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1 / 1.2,
mainAxisSpacing: 16.0,
crossAxisSpacing: 16.0,
),
itemCount: widget.categoryList.length,
itemBuilder: (context, index) {
return AllCategoryItem(
category: widget.categoryList[index],
index: index,
cartBloc: widget.cartBloc,
firebaseUser: widget.firebaseUser,
);
},
),
),
),
答案 0 :(得分:0)
例如使用 List.parse
函数:
someObjects.sort((a, b) => a.someProperty.compareTo(b.someProperty));