如何在 Flutter 中添加无限滚动?
How to add infinite scroll in Flutter?
我正在尝试使我的选项卡可滚动,这样如果我向下滚动,就会出现新内容。所以我想知道我们可以添加什么或者需要改进什么。
这是我的代码:
class ProductList extends StatelessWidget {
const ProductList({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.start,
runAlignment: WrapAlignment.start,
runSpacing: 8.0,
spacing: 15.0,
children: List.generate(10, (index) {
return SizedBox(
width: getProportionateScreenWidth(160),
child: GestureDetector(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 1.02,
child: Container(
padding: EdgeInsets.all(getProportionateScreenWidth(5)),
decoration: BoxDecoration(
color: kSecondaryColor.withOpacity(0.3),
borderRadius: BorderRadius.circular(15),
),
child: null),
),
const SizedBox(height: 10),
],
),
),
);
}),
);
}
}
这个插件可以像你想要的那样工作:Infinite ListView
我正在尝试使我的选项卡可滚动,这样如果我向下滚动,就会出现新内容。所以我想知道我们可以添加什么或者需要改进什么。
这是我的代码:
class ProductList extends StatelessWidget {
const ProductList({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.start,
runAlignment: WrapAlignment.start,
runSpacing: 8.0,
spacing: 15.0,
children: List.generate(10, (index) {
return SizedBox(
width: getProportionateScreenWidth(160),
child: GestureDetector(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 1.02,
child: Container(
padding: EdgeInsets.all(getProportionateScreenWidth(5)),
decoration: BoxDecoration(
color: kSecondaryColor.withOpacity(0.3),
borderRadius: BorderRadius.circular(15),
),
child: null),
),
const SizedBox(height: 10),
],
),
),
);
}),
);
}
}
这个插件可以像你想要的那样工作:Infinite ListView