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

overflow_view 封面
套件詳情v0.7.0

overflow_view

一個將子項顯示為一行的組件,如果空間不足,則在末尾顯示溢出指示器。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3萬
喜歡數
227
Pub 分數
150

安裝套件

flutter pub add overflow_view

套件介紹

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

OverflowView 是一個 Flutter 小部件,將其子組件水平排列,當空間不足時顯示溢出指示器(例如 '+' 或計數)。它非常適合緊湊的佈局,例如聊天介面中的使用者頭像或個人資料清單。該小部件會自動處理溢出,透過裁剪並加入視覺指示器,提升小螢幕上的可用性。它支援多個平台,包括行動裝置、網頁和桌面。

適用情境

  • 聊天頭像
  • 使用者清單預覽
  • 緊湊配置文件顯示
  • 響應式 UI 組件
  • 動態頭像組

主要特色

  • 自動溢出檢測
  • 可自定的溢出指示器
  • 水平佈局,帶間距
  • 跨平台支援
  • 靈活的兒童尺寸

適合對象

  • 具有動態頭像列表的 UI
  • 以行動裝置為首的響應式設計
  • 聊天和訊息應用
  • 個人檔案卡版面
  • 空間受限的介面

使用建議

  • 可能需要為溢出指示器自定義樣式
  • 有限的垂直溢出處理
  • 大型子項數量下的效能
  • 不適合複雜佈局
  • 依賴於父容器的約束

原始 README

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

overflow_view

A widget displaying children in a line with an overflow indicator at the end if there is not enough space.

Pub

Features

  • Renders children horizontally or vertically.
  • Has an overflow indicator builder so that you can display a widget showing the number of elements not rendered.
  • Can either constrain the children to the size of the first child or let them have the size they want.
  • Children can overlap each other by setting a negative spacing.

Overview

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  overflow_view:

In your library add the following import:

import 'package:overflow_view/overflow_view.dart';

Usage

OverflowView(
  // Either layout the children horizontally (the default)
  // or vertically.
  direction: Axis.horizontal,
  // The amount of space between children.
  spacing: 4,
  // The widgets to display until there is not enough space.
  children: <Widget>[
    for (int i = 0; i < _counter; i++)
      AvatarWidget(
        text: avatars[i].initials,
        color: avatars[i].color,
      )
  ],
  // The overview indicator showed if there is not enough space for
  // all chidren.
  builder: (context, remaining) {
    // You can return any widget here.
    // You can either show a +n widget or a more complex widget
    // which can show a thumbnail of not rendered widgets.
    return AvatarWidget(
      text: '+$remaining',
      color: Colors.red,
    );
  },
)
Constructors

There are two constuctors depending on what you want to do.

The OverflowView constructor will constrain all children to have the same size as the first one. This can be used for an avatar list for example.

The OverflowView.flexible constructor will let all children to determine their own size. This is less performant than the default one, but it's more flexible. This can be used for a menu bar for example.

Sponsoring

I'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me. By doing so, I will prioritize your issues or your pull-requests before the others.

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a feature, please send a pull request.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案