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

パッケージ詳細v1.2.0

focusable_control_builder

マウスおよびキーボードに適切に対応するカスタムコントロールを簡単に作成できます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1720
いいね数
52
Pub ポイント
140

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

flutter pub add focusable_control_builder

パッケージ概要

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

キーボードおよびマウスのフォーカス処理を適切に行うカスタムUIコントロールの作成を簡素化するFlutterパッケージです。フォーカス状態、アクセシビリティ、入力イベントをプラットフォーム間で一貫して管理するためのビルダーパターンを提供しています。開発者は、タブナビゲーション、キーボードショートカット、ポインター操作に適切に対応するボタン、スライダー、フォームフィールドなどのインタラクティブな要素を簡単に実装できます。このパッケージは、補助技術やタッチ以外の入力方法に依存するユーザーにとって、スムーズなユーザーエクスペリエンスを保証します。

用途

  • アクセシブルなフォーム入力を作成する
  • カスタムインタラクティブウィジェットの作成
  • 複雑なUIでキーボードナビゲーションを有効にする
  • スクリーンリーダーおよび補助技術のサポート
  • アプリでのタブナビゲーションの実装
  • デスクトップおよびウェブ用のレスポンシブコントロールの設計

主な機能

  • 組み込みのフォーカス状態管理
  • キーボードイベントの処理
  • マウスカーソルの統合
  • クロスプラットフォームの一貫性
  • アクセシビリティ対応のデザイン
  • シンプルなビルダー API

適している対象

  • アクセシブルなアプリを開発する開発者
  • デスクトップおよびウェブ向けのFlutterプロジェクト
  • キーボードユーザーのUXを最優先とするチーム
  • カスタムウィジェット作成者
  • 完全なキーボードナビゲーションを必要とするアプリ

注意事項

  • フォーカスの意味論について理解が必要
  • 視覚的フィードバックのための追加的なスタイリングが必要になる場合があります
  • 意味のあるUIパターンと併用するのが最適です
  • シンプルなタッチのみのインターフェースには不要です
  • 既存のフォーカスツリーとの統合には注意が必要な場合があります

元の README

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

focusable_control_builder

Using FocusableControlBuilder you can quickly create a new control that will work properly on all platforms and input devices.

Working "properly" entails support for:

  • tab key traversal
  • focus / rollover states
  • modified mouse cursor
  • support for keyboard shortcuts (Enter/Space by default)

Under the hood, this builder wraps the built in FocusableActionDetector and you can read there for more details about how it all works.

For more information on why you'd use these widgets, see this blog post: https://blog.gskinner.com/archives/2021/06/flutter-building-custom-components-with-focusableactiondetector.html

🔨 Installation

$ flutter pub add focusable_control_builder
⚙ Import
import 'package:focusable_control_builder/focusable_control_builder.dart';

🕹️ Usage

To create a custom button just implement the FocusableControlBuilder.builder method and assign an onPressed handler:

class MyCustomButton extends StatelessWidget {
  const MyCustomButton(this.label, {Key? key, required this.onPressed}) : super(key: key);
  final String label;
  final VoidCallback onPressed;
  @override
  Widget build(BuildContext context) {
    return FocusableControlBuilder(
        onPressed: onPressed,
        builder: (_, FocusableControlState control) {
          // Decide which colors to use, based on .isFocused and .isHovered
          Color outlineColor = control.isFocused ? Colors.black : Colors.transparent;
          Color bgColor = control.isHovered ? Colors.blue.shade100 : Colors.grey.shade200;
          // Return custom button contents
          return Container(
            padding: const EdgeInsets.all(8),
            child: Text(label),
            decoration: BoxDecoration(
              color: bgColor,
              border: Border.all(color: outlineColor, width: 1),
            ),
          );
        });
  }
}
Custom Mouse Cursor

FocusableControlBuilder will assume you want a "hand" cursor for your control, which is typically the case. If you'd like a different cursor, just assign it:

return FocusableControlBuilder(
    cursor: SystemMouseCursors.resizeDown,
    ...
);
Request Focus On Press

FocusableControlBuilder will assume you want your control to request focus when it is pressed. To disable, just set this to false:

return FocusableControlBuilder(
    requestFocusOnPress: false,
    ...
);
Custom Shortcuts

FocusableControlBuilder will create a default activation action which handles [Submit] and [Enter] keys. To create custom keyboard shortcuts you can set the .shortcuts and .actions parameters. This is a bit beyond the scope of this doc, but if you'd like to learn how, checkout the FocusableActionDetector docs which contain an example.

🐞 Bugs/Requests

If you encounter any problems please open an issue. If you feel the library is missing a feature, please raise a ticket on Github and we'll look into it. Pull request are welcome.

📃 License

MIT License

カテゴリー

ソースリポジトリ

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

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