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

pie_menu のカバー
パッケージ詳細v3.8.3

pie_menu

高度カスタマイズ可能な円形/径方向のコンテキストメニューを提供するFlutterパッケージ

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

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

flutter pub add pie_menu

パッケージ概要

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

Pie_menu は、カスタマイズ可能な円形または放射状のコンテキストメニューを提供するFlutterパッケージであり、直感的でスペース効率の高いユーザーインタラクションに最適です。開発者は、設定可能なスライス、アニメーション、ジェスチャーを備えたインタラクティブなパイ型メニューや作成できます。このパッケージはAndroid、iOS、Web、macOS、Windows、Linuxなど複数のプラットフォームをサポートしており、デバイス間で一貫した動作を保証します。色、サイズ、挙動などの広範なカスタマイズオプションにより、複数のアクションへの迅速なアクセスが必要なアプリのUIデザインを強化します。

用途

  • モバイルアプリにおけるクイックアクションの選択
  • クリエイティブツールにおける直感的なナビゲーション
  • ゲームインターフェースにおけるUIの向上
  • 生産性アプリにおける作業プロセスの最適化
  • AR/VRアプリケーションにおけるジェスチャー制御の提供

主な機能

  • 高度カスタマイズ可能なラジアルレイアウト
  • タッチ、タップ、ドラッグジェスチャーのサポート
  • スムーズなアニメーションと遷移
  • クロスプラットフォーム互換性
  • スライスサイズと間隔をカスタマイズ可能
  • 拡張可能なイベント処理

適している対象

  • ジェスチャー豊富なインターフェースを構築する開発者
  • 現代的なメニューの代替案を探しているUIデザイナー
  • コンパクトなアクションパネルを必要とするアプリ
  • インタラクティブな教育またはゲームアプリケーション
  • 複数のデバイスプラットフォームをターゲットにするプロジェクト

注意事項

  • アクセシビリティのための慎重なUXテストが必要になる可能性があります
  • 多数のメニュー項目によるパフォーマンスへの影響
  • 複雑な構成のための潜在的な学習曲線
  • シンプルな線形メニューには適していない
  • 小さな画面でのタッチターゲットのサイズに注意が必要です

元の README

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

Flutter Pie Menu 🥧

pub pub likes web apk app github buy me a coffee

A Flutter package providing a highly customizable circular/radial context menu, similar to Pinterest's.

Click here to try Flutter Pie Menu online!

Table of Contents

Usage

Wrap the widget that should respond to gestures with the PieMenu widget, and provide the menu with a list of PieActions to display as circular buttons.

PieMenu(
  onPressed: () => print('pressed'),
  actions: [
    PieAction(
      tooltip: const Text('like'),
      onSelect: () => print('liked'),
      child: const Icon(Icons.favorite), // Can be any widget
    ),
  ],
  child: ChildWidget(),
),

💡 Note that PieMenu must be a descendant of a PieCanvas widget.

Wrap your page, or any other desired widget for drawing the menu and the background overlay, with the PieCanvas widget.

For instance, if you want the menu to be displayed at the forefront, wrap your Scaffold with a PieCanvas as follows:

PieCanvas(
  child: Scaffold(
    body: YourScaffoldBody(
      ...
        PieMenu(),
      ...
    ),
  ),
),

💡 You can use the onPressed callback defined in PieMenu to handle tap events without needing an extra widget like GestureDetector.

Customization

You can customize the appearance and behavior of menus using PieTheme.

Using the theme attribute of the PieCanvas widget, you can specify a theme for all descendant PieMenu widgets.

PieCanvas(
  theme: PieTheme(),
  ...
    PieMenu(), // Uses the canvas theme
  ...
    PieMenu(), // Uses the canvas theme
  ...
),

If you want to specify menu-specific themes, you can use the theme attribute of the PieMenu widget.

PieMenu(
  theme: PieTheme(), // Overrides the canvas theme
),

It is also possible to copy the canvas theme with additional parameters, but ensure you are accessing it with the correct context.

PieMenu(
  theme: PieTheme.of(context).copyWith(
    ...
  ),
),
Button themes

Button background and icon colors are defined by the theme's buttonTheme and buttonThemeHovered properties. You can create custom PieButtonTheme instances for your canvas and menu themes.

PieTheme(
  buttonTheme: PieButtonTheme(),
  buttonThemeHovered: PieButtonTheme(),
),

You can also style the buttons using the decoration property of PieButtonTheme.

PieButtonTheme(
  decoration: BoxDecoration(),
),
Custom button widgets

If you wish to use custom widgets inside buttons instead of just icons, use PieAction.builder(). Its builder provides the hover state as a parameter.

PieAction.builder(
  tooltip: const Text('like'),
  onSelect: () => print('liked'),
  builder: (hovered) {
    return Text(
      '<3',
      style: TextStyle(
        color: hovered ? Colors.green : Colors.red,
      ),
    );
  },
),
Display angle of menu buttons
Display angle of menu buttons

To disable dynamic angle calculation and have the menu appear at a fixed angle, set the customAngle and customAngleAnchor attributes of PieTheme.

PieTheme(
  customAngle: 90, // In degrees
  customAngleAnchor: PieAnchor.center, // start, center, end
),

You can also use customAngleDiff or spacing to adjust the angle between buttons, and angleOffset to rotate the menu.

Specific menu position

Use the menuAlignment attribute of PieTheme to make the menu appear at a specific position regardless of the press location. Combine it with menuDisplacement to fine-tune the position.

PieTheme(
  menuAlignment: Alignment.center,
  menuDisplacement: Offset(0, 0),
),
Regular press, long press or right click to open the menu

Use the regularPressShowsMenu, longPressShowsMenu, and longPressDuration attributes of PieTheme to customize the menu opening behavior.

PieTheme(
  regularPressShowsMenu: true,
  longPressShowsMenu: true,
  longPressDuration: const Duration(milliseconds: 500),
),

Use the rightClickShowsMenu and leftClickShowsMenu attributes of PieTheme to customize mouse button behavior.

PieTheme(
  rightClickShowsMenu: true,
  leftClickShowsMenu: false,
),

Controllers and callbacks

To open, close, or toggle a menu programmatically, assign a PieMenuController to it.

// Create a controller inside a stateful widget.
final _pieMenuController = PieMenuController();

// Assign the controller to a PieMenu.
PieMenu(
  controller: _pieMenuController,
  ...
),

// Control the menu using the controller.
_pieMenuController.open(
  menuAlignment: Alignment.center,
);

If you need to perform actions when the menu is toggled, use the onToggle callback of PieMenu or the onMenuToggle callback of PieCanvas.

PieMenu(
  onToggle: (menuOpen) => print('Menu ${menuOpen ? 'opened' : 'closed'}'),
  ...
),

PieCanvas(
  onMenuToggle: (menuOpen) => print('A menu ${menuOpen ? 'opened' : 'closed'}'),
  ...
),

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

github

Donation

If you find this package useful, please consider donating to support the project.

buy me a coffee

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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