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

expand_widget 封面
插件详情v3.1.1

expand_widget

轻松展开和收起小部件集合或文本的能力

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
5770
喜欢数
147
Pub 分数
150

安装插件

flutter pub add expand_widget

插件介绍

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

expand_widget 包提供了一种简单直观的方法来动画化小部件或文本内容的展开和收缩。它能够实现折叠与展开状态之间的平滑过渡,非常适合创建交互式 UI 元素,如折叠面板或可折叠区域。该包设计时注重易用性,可无缝集成到跨多个平台的 Flutter 应用中。该包支持自定义动画、持续时间控制以及灵活的内容布局,适用于小型组件和复杂 UI 结构。

适合场景

  • 创建可折叠的折叠面板
  • 构建交互式常见问题部分
  • 列表中动画显示内容
  • 设计响应式卡片界面
  • 实现动态表单部分

主要特点

  • 流畅的展开/收起动画
  • 可自定义的动画持续时间
  • 支持任何小部件作为内容
  • 与现有布局的轻松集成
  • 灵活的触发机制

适合对象

  • 寻求简单扩展控件的开发者
  • UI 设计师构建交互式卡片
  • 需要动态内容切换的应用程序
  • 跨平台 Flutter 应用
  • 具有折叠式界面的项目

使用建议

  • 可能会影响大型部件树的性能
  • 需要仔细处理状态管理
  • 动画行为取决于父布局约束
  • 未针对极高频率的切换进行优化
  • 与轻量级内容配合使用,以获得最佳响应速度

原始 README

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

Expand Widget

Package style: very good analysis Build Patreon License

This Dart package offers developers a streamlined library of Flutter widgets, useful for expanding widgets and text views, when users interact with them.

There are two main 'expand' widgets:

  • Expand Child: Useful to show more widgets related to the content already visible by the user.
  • Expand Text: Useful when texts can be quite big for a certain screen. It adds the ability to show the full content when the user wants to.

Features

  • The ExpandIndicatorStyle parameter allows you to select various render options, related to the expand arrow itself.

  • Hide the arrow widget when the view is being expanded, using the hideIndicatorOnExpand parameter.

  • Custimze the arrow widget itself: color, size, padding, icon...

  • You can also provide your own widget for the expand indicator, using the indicatorBuilder for both expaning widgets.

  • Use custom expanding hint strings! By default, it will use the ones provided by MaterialLocalizations.

  • Expand text view with swipe-down gestures, using the expandOnGesture, which by default is set to false.

  • You can also customize expand animation duration and curve easilly.

  • The collapsedVisibilityFactor (exclusive to the ExpandChild widget), allows the reveal of a section of the hidden content.

Example

Here is an example of a simple use of this package, featuring the ExpandChild & ExpandText widgets.

If you want to take a deeper look at the example, take a look at the example folder provided with the project.

  • ExpandChild
ExpandChild(
  child: Column(
    children: [
      OutlineButton(
        child: Text('Button1'),
        onPressed: () => print('Pressed button1'),
      ),
      OutlineButton(
        child: Text('Button2'),
        onPressed: () => print('Pressed button2'),
      ),
      OutlineButton(
        child: Text('Button3'),
        onPressed: () => print('Pressed button3'),
      ),
    ],
  ),
),
  • ExpandText
ExpandText(
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
  textAlign: TextAlign.justify,
),

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Built with

Authors

License

This project is licensed under the GNU GPL v3 License - see the LICENSE file for details.

所属分类

源码仓库

使用此插件的项目