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

expandable_widgets 封面
插件详情v1.0.3+1

expandable_widgets

一个包为 Flutter 提供了用 100% Dart 编写的可展开小部件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
13
喜欢数
36
Pub 分数
140

安装插件

flutter pub add expandable_widgets

插件介绍

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

expandable_widgets 包提供了一套可自定义的、100% 基于 Dart 的可展开小部件,适用于 Flutter。它使开发者能够创建带有平滑动画的可折叠内容区域,非常适合用于卡片或扩展项中组织信息。该包支持 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台,确保在各种设备上行为一致。通过 pub add 简单集成,它通过允许动态控制内容可见性来提升用户体验。

适合场景

  • 创建可折叠的常见问题部分
  • 构建交互式产品详情卡片
  • 设计可扩展的导航菜单
  • 实现动画折叠面板
  • 在紧凑布局中显示详细信息

主要特点

  • 平滑的动画过渡
  • 完全可自定义的外观
  • 支持所有主要的 Flutter 平台
  • 轻量级且纯 Dart 实现
  • 与现有 UI 的轻松集成

适合对象

  • 开发响应式卡片式界面的开发者
  • 需要交互式内容切换的应用程序
  • 需要轻量级扩展组件的项目

使用建议

  • 可能需要额外的样式设置以适应复杂布局
  • 有限的内置主题选项
  • 未针对超大数据集进行优化

原始 README

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

Expandable Widgets

A package provides expandable widgets for Flutter, written in 100% Dart.

Why?

Fast

There are various ways of getting expandable behaviour in Flutter. This package provides boilerplate code and reduces production time.

Inclusive

Expandable Widgets offers a variety of uses. Check More Usecases

Easy

You can obtain the basic expandable widgets by writing one single line of code.

Examples

General Use:

You can use Expandable with two required parameters.

Expandable(
  firstChild: const Text('Hello world!'),
  secondChild: Center(child: const Text('Hello world!')),
),

Extended Example:

If you add subChild argument you will get an expandable with subtitle. See 1.0.2 or older versions for previous extended expandables.

Expandable(
  firstChild: Padding(
    padding: const EdgeInsets.all(8.0),
    child: Text(data, maxLines: 3, textAlign: TextAlign.justify),
  ),
  secondChild: Padding(
    padding: const EdgeInsets.all(8.0),
    child: Text(data, maxLines: 3, textAlign: TextAlign.justify),
  ),
  subChild: Text("Show Details"),
),

Expandable Text:

You can use ExpandableText by giving the required parameter, textWidget. ExpandableText will handle the rest.

ExpandableText(textWidget: Text(data, maxLines: 3),

More Usecases

Expandable

Let's say you want to use Expandable and Flutter's AnimatedIcon at the same time.

Just add the relevant animationController. Expandable will handle the rest!

Row(
  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  children: [
    Expandable(
      firstChild: Padding(
        padding: const EdgeInsets.only(right: 8.0),
        child: Text('Settings', style: TextStyle(fontSize: 18)),
      ),
      secondChild: Column(children: [Text('Option 1'), Text('Option 2'), Text('Option 3')]),
      animationController: _animationController,
      arrowLocation: ArrowLocation.left,
      arrowWidget: Padding(
        padding: const EdgeInsets.all(8.0),
        child: AnimatedIcon(icon: AnimatedIcons.menu_close, progress: _animation, size: 16),
      ),
    ),

Even more, one can combine AnimatedIcon and Expandable's rotation animation.

Give the same animation to AnimatedIcon and Expandable and finally, do not forget to add relevant animationController to Expandable.

    Expandable(
      firstChild: Padding(
        padding: const EdgeInsets.only(right: 8.0),
        child: Text('Settings', style: TextStyle(fontSize: 18)),
      ),
      secondChild: Column(children: [Text('Option 1'), Text('Option 2'), Text('Option 3')]),
      animation: _animation,
      animationController: _animationController,
      arrowLocation: ArrowLocation.left,
      arrowWidget: Padding(
        padding: const EdgeInsets.all(8.0),
        child: AnimatedIcon(icon: AnimatedIcons.menu_close, progress: _animation, size: 16),
      ),
    ),
  ],
),

Nested Expandable Widgets

Expandable(
  firstChild: Text('Nested Expandable Widgets'),
  secondChild: Expandable(
    borderRadius: BorderRadius.zero,
    boxShadow: [],
    firstChild: Text('Second Expandable'),
    secondChild: Expandable(
      borderRadius: BorderRadius.zero,
      boxShadow: [],
      firstChild: Text('Third Expandable'),
      secondChild: Center(child: Text('The End')),
    ),
  ),
),

ExpandableText

You can change the location of the arrow

ExpandableText(
  textWidget: Text(data).copyWith(maxLines: 3),
  arrowLocation: ArrowLocation.bottom,
  finalArrowLocation: ArrowLocation.bottom,
),

You can use helper text

ExpandableText(textWidget: Text(data, maxLines: 3), helper: Helper.text),

Customized ExpandableText with helper text

ExpandableText(
  textWidget: Text(data, maxLines: 5, textAlign: TextAlign.justify),
  backgroundColor: Colors.white,
  helper: Helper.text,
  helperTextList: const ['...More', '...Less'],
  helperTextStyle: const TextStyle(color: Colors.orange, fontWeight: FontWeight.bold),
  boxShadow: const [BoxShadow(color: Colors.orange, offset: Offset(2, 2), blurRadius: 4)],
  borderRadius: BorderRadius.circular(20.0),
  padding: const EdgeInsets.all(12.0),
  onPressed: () => print('hi!'),
),

Or you can remove the helper

ExpandableText(textWidget: Text(data, maxLines: 3), helper: Helper.none),

Known issues

For more info please see example.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。