搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。