请如何在颤抖的一页中创建拖曳列表视图

时间:2020-01-09 14:51:07

标签: flutter flutter-animation

请创建两个包含容器的listeview

我的意思是喜欢那些照片:

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

您可能想学习如何使用此软件包https://pub.dev/packages/flutter_staggered_grid_view

由于我已经在中等规模的应用程序中实现了代码,所以我只能共享一小段代码,而不能共享全部代码;但它应该看起来像这样:

StaggeredGridView.countBuilder(
crossAxisCount: 1,
padding: const EdgeInsets.all(8),
itemCount: pharmacyBranchSearchedProvider.pharmacyBranches.length,
itemBuilder: (context, index) {
    PharmacyBranch pharmacyBranch =
        pharmacyBranchSearchedProvider.pharmacyBranches[index];

    return PharmacyBranchCard(
    pharmacyBranch: pharmacyBranch,
    onPressed: () {
        Provider.of<ProductFilterProvider>(context)
            .resetProductTypesWithJsonMap(
                pharmacyBranch.productTypes);
        PageRouter.push(
            context,
            PharmacyBranchProductSearchPage(
            pharmacyBranch: pharmacyBranch,
            ));
    },
    );
},
staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
)

您可以构建您所引用的东西,每行列出多个产品;上面的代码中的crossAxisCount定义了每行将显示多少个小部件。