搜索插件、代码仓与 APP 分类

overscroll_pop 封面
插件详情v0.1.1

overscroll_pop

一个用于滚动视图的 Flutter 小部件,当过度滚动时会像 iOS 上的 Pinterest 和 Instagram 应用一样弹回。

AndroidiOSWeb
近 30 天下载
62
喜欢数
123
Pub 分数
130

安装插件

flutter pub add overscroll_pop

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可在 ScrollViews 中启用 iOS 风格的过度滚动返回行为,模拟 Pinterest 和 Instagram 等应用中常见的交互式下拉刷新或返回手势。通过允许用户在可滚动列表边缘过度滚动来实现返回导航,从而提升用户体验。兼容 Android、iOS 和 Web,可无缝集成到现有可滚动控件中,无需复杂设置。适用于希望复制原生 iOS 导航模式的应用。

适合场景

  • 在滚动视图中实现 iOS 风格的返回手势
  • 在社交媒体信息流中创建直观的导航
  • 增强基于列表的界面中的用户交互
  • 在移动应用中添加自然的滚动效果
  • 支持向左滑动返回功能

主要特点

  • iOS 类似回弹弹出行为
  • 与 ScrollView 小部件的无缝集成
  • 跨平台支持(Android、iOS、Web)
  • 所需最小配置
  • 流畅且响应迅速的手势检测

适合对象

  • 开发社交媒体应用的开发者
  • Teams 复制 iOS 原生行为
  • 需要直观的滚动导航的应用程序
  • Flutter 项目针对移动平台
  • 以用户体验为中心的应用程序,优先考虑手势反馈

使用建议

  • 可能与其他手势检测器冲突
  • 在非iOS平台上,行为可能感觉不一致
  • 需要在不同设备上进行仔细测试
  • 不适合所有用户界面设计
  • 手势阈值的自定义选项有限

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

overscroll_pop

A Flutter widget for Scrollview, pop when overscroll like Instagram, Pinterest, ...

Demo Demo Demo

Getting Started

  1. Include the package to your project as dependency:
dependencies:
  	overscroll_pop: <latest version>
  1. Use the widget:

Wrap your Scaffold or top widget by OverscrollPop, every ScrollView widget (Listview, GridView, PageView, CustomScrollView, ...) which has scroll physics ClampingScrollPhysics(important) will have overscroll to pop effect.

    MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Overscroll Example'),
        ),
        body: Builder(
          builder: (c) => Center(
            child: Hero(
              tag: '${ScrollToPopOption.start}${DragToPopDirection.toRight}',
              child: ElevatedButton(
                onPressed: () => pushPage(
                  c,
                  (BuildContext context, _, __) => VerticalScrollview(
                    scrollToPopOption: ScrollToPopOption.start,
                    dragToPopDirection: DragToPopDirection.toRight,
                  ),
                ),
                child: Text('Vertical scrollview ${ScrollToPopOption.start}'),
              ),
            ),
          ),
        ),
      ),
    );

    class VerticalScrollview extends StatelessWidget {
      final ScrollToPopOption scrollToPopOption;
      final DragToPopDirection? dragToPopDirection;

      const VerticalScrollview({
        Key? key,
        this.scrollToPopOption = ScrollToPopOption.start,
        this.dragToPopDirection,
      }) : super(key: key);

      @override
      Widget build(BuildContext context) {
        return OverscrollPop(
          scrollToPopOption: scrollToPopOption,
          dragToPopDirection: dragToPopDirection,
          child: Container(
            clipBehavior: Clip.hardEdge,
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.0)),
            child: Scaffold(
              appBar: PreferredSize(
                preferredSize: Size.fromHeight(kToolbarHeight),
                child: Hero(
                  tag: '$scrollToPopOption${dragToPopDirection ?? ''}',
                  child: AppBar(
                    title: Text(
                      'Vertical Scrollview',
                      overflow: TextOverflow.visible,
                    ),
                  ),
                ),
              ),
              body: ListView.builder(
                physics: const ClampingScrollPhysics(),
                itemBuilder: (_, index) => Container(
                  height: 160.0,
                  margin: const EdgeInsets.symmetric(vertical: 8.0),
                  color: index % 2 == 0 ? Colors.cyanAccent : Colors.orangeAccent,
                  alignment: Alignment.center,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text(scrollToPopOption.toString()),
                      if (dragToPopDirection != null)
                        Text(dragToPopDirection.toString()),
                    ],
                  ),
                ),
                itemCount: MediaQuery.of(context).size.height ~/ 160.0 + 2,
              ),
            ),
          ),
        );
      }
    }

If your Scaffold does not contain any ScrollView and want to achieve drag to pop effect, wrap your Scaffold or top widget by DragToPop instead (Example).

Quick push route config helper:

pushOverscrollRoute(
    context: context,
    child: <your scaffold/widget>,
    // scrollToPopOption: <your ScrollToPopOption>,
    // dragToPopDirection: <your DragToPopDirection>,
    // other route configs
)

pushDragToPopRoute(
    context: context,
    child: <your scaffold/widget>,
    // other route configs
)
  1. Configure scroll direction and add extra drag to pop:
    • By default, the effect only apply for overscroll at the start of ScrollView (top edge of vertical scroll, left edge of horizontal scroll)

      VStart HStart

    • To enable the end edge (or both edges) for overscroll to pop, set scrollToPopOption to ScrollToPopOption.end (or ScrollToPopOption.both)

      OverscrollPop(
        scrollToPopOption: ScrollToPopOption.end, // or ScrollToPopOption.both
        ...
      )
      

      VEnd HEnd

    • Beside overscroll, you can config the other drag direction to achieve the pop effect by passing dragToPopDirection

      OverscrollPop(
        dragToPopDirection: DragToPopDirection.toTop, //  toTop, toBottom, toLeft, toRight, horizontal and vertical
        ...
      )
      
      1. Vertical scroll: drag to left, right or horizontal (both left and right) VStartToLeft VStartToLeft

      2. Horizontal scroll: drag to top, bottom or vertical (both top and bottom) HEndToTop HEndToBottom

所属分类

源码仓库

使用此插件的项目

暂无相关数据。