搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目