搜尋套件、儲存庫與 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-like 過捲彈出行為
  • 與 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。