如何在flutter中制作磁力滚动效果?

问题描述 投票:0回答:1

我的 flutter 项目中有一个滚动视图,它包含 3 个容器,每个容器的高度不同。我想创建一种效果,如果滚动,视图会捕捉到下一个或上一个

Container

我想要的结果

no scroll -> first scroll -> second scroll

代码

SingleChildScrollView(
  child: Column(
    children: [
      Container(
        height: 400,
        width: double.maxFinite,
        color: Colors.amber,
      ),
      Container(
        height: 500,
        width: double.maxFinite,
        color: Colors.red,
      ),
      Container(
        height: 100,
        width: double.maxFinite,
        color: Colors.green,
      ),
    ],
  ),
),

目前我没有那种捕捉效果,它只是一个普通的滚动视图。 使用

PageView
也行不通,因为你需要每个最大高度的整页。

flutter dart
1个回答
0
投票

您可以使用 scroll_snap_list 包。

© www.soinside.com 2019 - 2024. All rights reserved.