You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter:如何为列表项选中时添加侧滑切换动画?

Flutter 笔记列表与详情页双向侧滑动画实现需求

我在Flutter应用中做了一个笔记列表,希望实现点击列表项查看详情时触发侧滑动画(效果为横向滑入),返回时动画反向播放。目前通过Provider更新selectedNote来切换列表视图(NotesStreamWidget)与详情视图,需要为该视图切换添加双向侧滑动画。

现有代码如下:

SafeArea(
          child: Column(
            children: [
              const DisplayProfileWidget(),
              ListContainerWidget(
                child: selectedNote == null
                    ? const NotesStreamWidget() // 点击列表项时通过Provider设置选中笔记,切换为详情视图
                    : Column(
                        mainAxisSize: MainAxisSize.max,
                        children: [
                          const Expanded(
                            child: NoteHeaderWidget(),
                          ),
                          Expanded(
                            flex: 3,
                            child: Text(
                              selectedNote.title.toUpperCase(),
                              style: const TextStyle(
                                fontSize: 20,
                                fontWeight: FontWeight.bold,
                              ),
                            ),
                          ),
                        ],
                      ),
              ),
            ],
          ),
        ),

切换前后界面截图:

  • 列表视图:列表视图截图
  • 详情视图:详情视图截图

内容的提问来源于stack exchange,提问作者DarkSide77

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 09:13:23