パッケージ、リポジトリ、アプリカテゴリを検索

contextualactionbar のカバー
パッケージ詳細v3.1.0

contextualactionbar

Flutter用のコンテキストアクションバー(CAB)の回避策。CABはアプリバーを置き換える上部アプリバーであり、選択されたアイテムに対してコンテキスト関連の操作を提供します。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
119
いいね数
66
Pub ポイント
150

パッケージをインストール

flutter pub add contextualactionbar

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

contextualactionbar パッケージは、Flutter でコンテキストアクションバー(CAB)を実装するための回避策を提供し、アイテムが選択された際に標準のアプリバーを置き換える動的な上部アプリバーを可能にします。Android、iOS、Web、macOS、Windows、Linux など複数のプラットフォームで使用できるように設計されており、選択モード中にターゲット制御を提供することでユーザーインタラクションを強化します。既存の Flutter アプリにスムーズに統合でき、カスタムスタイルや動作もサポートしています。リストまたはグリッドインターフェースで一括操作が必要な場合に特に有用です。

用途

  • リスト内のバッチアイテム選択
  • グリッド内のコンテキストに応じた操作
  • モバイルアプリにおけるユーザーインタラクションの強化
  • カスタマイズ可能なアクションオーバーレイ
  • クロスプラットフォーム実装
  • 選択モードのUI向上

主な機能

  • アプリバーの動的置換
  • 複数のプラットフォームに対応
  • カスタマイズ可能な操作ボタン
  • 選択モードとの統合
  • 軽量で実装が簡単
  • すべてのデバイス向けのレスポンシブデザイン

適している対象

  • インタラクティブなリストインターフェースを構築している開発者
  • バッチ操作を必要とするアプリ
  • クロスプラットフォームモバイルアプリケーション
  • 選択ベースのワークフローを備えたUI
  • プラットフォームに依存しないCABソリューションを求めるチーム
  • コンテキストアクションのサポートが必要なFlutterプロジェクト

注意事項

  • 選択状態の手動処理が必要です
  • 制限された組み込みアニメーション
  • 一貫性を保つために追加のスタイリングが必要になる場合があります
  • スクロール可能な要素との適切な統合に依存する
  • シンプルな静的UIには適していません
  • 状態管理パターンと併用するのが最適です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Flutter contextual action bar(CAB)

CAB & Flutter

CAB is a top app bar that replace the application app bar to provide contextual actions to selected items. Check the material implementation and requirement here

Flutter does not natively support CAB yet. see issue Until CAB is natively supported, this package should provide you with an elegant way to implement the contextual action bar in flutter.

How it works

  • ContextualScaffold
  • ContextualAppBar
  • ContextualAction
  • ContextualActionWidget

ContextualScaffold<?>

The ContextualScaffold<?> is similar to the normal material Scaffold except that it also takes a required contextualAppBar.

ContextualScaffold<?>(
      contextualAppBar: ContextualAppBar(),
      appBar: AppBar(),
      body: Body(),
    )

You can provide multiple ContextualScaffold as needed

ContextualAppBar<?>

The ContextualAppBar<?> is similar to the normal material Appbar but takes a counterBuilder instead of title and also a contextualActions instead of actions.

 ContextualAppBar(
      counterBuilder: (int itemsCount){
        return Text("$itemsCount Selected");
      },
      contextualActions: <ContextualAction>[],
    )

ContextualAction<?>

The ContextualAction<?> allows you to take actions on the selected items, with the help of itemsHandler callback.

ContextualAction(
            itemsHandler: (List<?> items) {
              items.forEach((item) {
                Scaffold.of(context).showSnackBar(SnackBar(
                  content: Text("$item saved"),
                ));
              });
            },
            child: Icon(Icons.save),
          ),

ContextualActionWidget<?>

You can use the ContextualActionWidget anywhere in the ContextualActionScaffold body to notify ContextualActionScaffold that an item have been selected in order to show the ContextualAppBar.

   ContextualActionWidget(
          data: ?,
          child: ChildWidget(),
        )

Note: It is important that the child widget does not handle onLongPress.

A closer look at ContextualActionWidget<?>

The ContextualActionWidget<?> takes other optional parameters like

  • selectedColor
  • selectedWidget
  • unselectedWidget

The selectedColor is the color of the background for the selected item, it defaults to the splash color, if not provided. The selectedColor works well with ListTile.

selectedWidget and unselectedWidget are stacked on top of the provided child widget. By default, they are positioned at the center of the provided child widget. Since They are stacked, you can use Row, Align, Positioned Widget or any other combination of widgets to position them where desired.

The selectedWidget is shown when the ActionMode is enabled and the item is selected, while the unselectedWidget is shown when ActionMode is enabled and the item is not selected. See example(status_saver) image below with both the selectedWidget and unselectedWidget aligned to the top-right corner.

ActionMode

This contextual action bar workaround does not support zero item in the ActionMode.

  • Use the ActionMode.addItem<?> to add an item to the selected items. If this is the first selection, the ActionMode is will be enabled.

  • Use the ActionMode.addItems<?> to add a list of items.

  • Use the ActionMode.disable<?> to disable and deselect all selected items.

  • Use the ActionMode.enabledStream<?> to emit true or false depending on if the Action mode is enabled or disabled respectively.

Note: In most cases, you won't need to use ActionMode.disable<?> because the package already do that for you where needed.

Study complete examples at example page. If you like the project, don't forget to star ⭐️

Other Packages authored by me

License

This package is licensed under the MIT license. See LICENSE for details.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。