搜尋套件、儲存庫與 APP 分類

draggable_scrollbar 封面
套件詳情v0.1.0

draggable_scrollbar

一個可拖曳的捲軸,可用於快速瀏覽垂直清單。額外選項是在捲軸滑塊旁顯示標籤,以提供目前項目資訊。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
8120
喜歡數
404
Pub 分數
140

安裝套件

flutter pub add draggable_scrollbar

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

draggable_scrollbar 套件透過提供一個可拖曳的捲軸條與一個可選的標籤來增強 Flutter 中垂直清單的導航體驗,該標籤會顯示目前可見項目之相關資訊。使用者可以透過拖曳捲軸條滑塊快速滾動長清單,從而提升易用性與可存取性。標籤會動態更新以反映目前位置,提供視覺反饋。此套件專為與 ListView 及其他可捲動元件無縫整合而設計,支援所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 快速瀏覽長清單
  • 增強可滾動內容的可存取性
  • 提升資料密集型應用中的使用者體驗
  • 在捲動時提供視覺反饋
  • 自定義垂直列表中的滾動行為

主要特色

  • 可拖曳的捲動條滑塊
  • 動態標籤,顯示目前項目資訊
  • 跨平台支援
  • 與 ListView 的輕鬆整合
  • 可自訂外觀
  • 平滑滾動互動

適合對象

  • 具有長垂直列表的應用程式
  • 以可存取性為導向的應用程式
  • 資料密集型儀表板
  • 需要直覺滾動的使用者介面
  • 尋求增強捲動使用者體驗的開發者

使用建議

  • 可能需要額外的樣式設定以獲得最佳外觀
  • 在小螢幕上,標籤位置可能需要調整
  • 對極大型清單的效能影響
  • 僅限垂直滾動
  • 需要正確的上下文以進行標籤文字渲染

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Community: draggable_scrollbar

Draggable Scrollbar

Pub

A scrollbar that can be dragged for quickly navigation through a vertical list. Additionaly it can show label next to scrollthumb with information about current item, for example date of picture created

Usage

You can use one of the three built-in scroll thumbs, or you can create a custom thumb for your own app!

You can play with all of these examples by running the app found in the example folder.

Example

Semicircle Thumb
DraggableScrollbar.semicircle(
  controller: myScrollController,
  child: GridView.builder(
    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
      crossAxisCount: 5,
    ),
    controller: myScrollController,
    padding: EdgeInsets.zero,
    itemCount: 1000,
    itemBuilder: (context, index) {
      return Container(
        alignment: Alignment.center,
        margin: EdgeInsets.all(2.0),
        color: Colors.grey[300],
      );
    },
  ),
);
Arrows thumb + label
DraggableScrollbar.arrows(
  labelTextBuilder: (double offset) => Text("${offset ~/ 100}"),
  controller: myScrollController,
  child: ListView.builder(
    controller: myScrollController,
    itemCount: 1000,
    itemExtent: 100.0,
    itemBuilder: (context, index) {
      return Container(
        padding: EdgeInsets.all(8.0),
        child: Material(
          elevation: 4.0,
          borderRadius: BorderRadius.circular(4.0),
          color: Colors.purple[index % 9 * 100],
          child: Center(
            child: Text(index.toString()),
          ),
        ),
      );
    },
  ),
);
Rounded Rectangle Thumb
DraggableScrollbar.rrect(
  controller: myScrollController,
  child: ListView.builder(
    controller: myScrollController,
    itemCount: 1000,
    itemExtent: 100.0,
    itemBuilder: (context, index) {
      return Container(
        padding: EdgeInsets.all(8.0),
        child: Material(
          elevation: 4.0,
          borderRadius: BorderRadius.circular(4.0),
          color: Colors.green[index % 9 * 100],
          child: Center(
            child: Text(index.toString()),
          ),
        ),
      );
    },
  ),
);
Custom
DraggableScrollbar(
  controller: myScrollController,
  child: ListView.builder(
    controller: myScrollController,
    itemCount: 1000,
    itemExtent: 100.0,
    itemBuilder: (context, index) {
      return Container(
        padding: EdgeInsets.all(8.0),
        child: Material(
          elevation: 4.0,
          borderRadius: BorderRadius.circular(4.0),
          color: Colors.cyan[index % 9 * 100],
          child: Center(
            child: Text(index.toString()),
          ),
        ),
      );
    },
  ),
  heightScrollThumb: 48.0,
  backgroundColor: Colors.blue,
  scrollThumbBuilder: (
    Color backgroundColor,
    Animation<double> thumbAnimation,
    Animation<double> labelAnimation,
    double height, {
    Text labelText,
  }) {
    return FadeTransition(
      opacity: thumbAnimation,
      child: Container(
        height: height,
        width: 20.0,
        color: backgroundColor,
      ),
    );
  },
);

所屬分類

原始碼儲存庫

使用此套件的專案