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

draggable_float_widget のカバー
パッケージ詳細v0.1.0

draggable_float_widget

これは、スクロールビューのスクロールイベントによって表示/非表示を制御できるドラッグ可能で浮遊型のFlutterウィジェットです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
17.7万
いいね数
116
Pub ポイント
150

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

flutter pub add draggable_float_widget

パッケージ概要

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

スクロールイベントに応じて自動的に表示または非表示になるドラッグ可能な浮動ウィジェットを提供するFlutterパッケージです。浮動アクションボタンやユーザーのスクロール動作に従うカスタムオーバーレイのようなインタラクティブなUI要素を作成するのに最適です。ウィジェットは画面内で自由に移動でき、スクロール方向およびScrollView内の位置に基づいて可視性を自動調整します。Android、iOS、Web、macOS、Windows、Linuxなど、すべての主要プラットフォームをサポートしています。

用途

  • スクロール可能なリスト内のフローティングアクションボタン
  • スクロールに反応するインタラクティブなオーバーレイ
  • カスタムドラッグ可能なUIコンポーネント
  • モバイルアプリのナビゲーションの向上
  • Webアプリケーション内のダイナミックUI要素

主な機能

  • ドラッグ可能な位置指定
  • スクロールでトリガーされる可視性制御
  • クロスプラットフォーム互換性
  • ドラッグ中のスムーズなアニメーション
  • 表示/非表示のしきい値をカスタマイズ可能
  • 複数のプラットフォームターゲットをサポート

適している対象

  • スクロールに応じたUIを構築する開発者
  • 動的なフローティング要素を必要とするモバイルおよびウェブアプリ
  • ジェスチャーに基づくインタラクションを実装するデザイナー
  • 複雑なオーバーレイ要件を持つアプリ
  • マルチプラットフォームデプロイメントをターゲットとするチーム

注意事項

  • 大規模なリストではパフォーマンスチューニングが必要になる場合があります
  • 複雑なスクロール動作には、可視性ロジックのカスタマイズが必要になる場合があります
  • 制限された組み込みスタイルオプション
  • 静的フローティング要素には適していない
  • ネストされたスクロールビューでは注意深く扱う必要がある

元の README

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

draggable_float_widget

This is a draggable and floating Flutter widget, which can control its visibility through the scrolling event of ScrollView.

Usage

To use this plugin, add draggable_float_widget as a dependency in your pubspec.yaml file.

constructor
  • the constructor of component

    DraggableFloatWidget({
      Key? key,
      this.width = defaultWidgetWidth,
      this.height = defaultWidgetHeight,
      this.eventStreamController,
      this.config = const DraggableFloatWidgetBaseConfig(),
      required this.child,
      this.onTap,
    }) : super(key: key);
    
  • special field instructions

    property description default
    eventStreamController The [StreamController] of [OperateEvent] null
    config the base config of [DraggableFloatWidget] DraggableFloatWidgetBaseConfig()
  • the base config of component

    DraggableFloatWidgetBaseConfig({
      this.isFullScreen = true,
      this.appBarHeight = kToolbarHeight,
      this.initPositionXInLeft = true,
      this.initPositionYInTop = true,
      this.initPositionYMarginBorder = 0,
      this.borderLeft = defaultBorderWidth,
      this.borderRight = defaultBorderWidth,
      this.borderTop = defaultBorderWidth,
      this.borderTopContainTopBar = false,
      this.borderBottom = defaultBorderWidth,
      this.exposedPartWidthWhenHidden = defaultExposedPartWidthWhenHidden,
      this.animDuration = const Duration(milliseconds: 300),
      this.delayShowDuration = const Duration(milliseconds: 500),
      this.debug = false,
    });
    
example
  • the first, add scroll listener

    ⚠️Ignore this step if the component is not affected by ScrollView scrolling, and you don't need to pass an StreamController instance into the instance.

    NotificationListener(
      onNotification: (notification) {
        if (notification is ScrollStartNotification) {
          eventStreamController.add(OperateEvent.OPERATE_HIDE);
        } else if (notification is ScrollEndNotification) {
          eventStreamController.add(OperateEvent.OPERATE_SHOW);
        }
        return true;
      },
      child: ListView(...),
    )
    
  • the first way: stack mode

    Stack(
      children: [
        listView,
        DraggableFloatWidget(
          child: child,
          eventStreamController: eventStreamController,
          config: DraggableFloatWidgetBaseConfig(
            isFullScreen: false,
            initPositionYInTop: false,
            initPositionYMarginBorder: 50,
            borderBottom: navigatorBarHeight + defaultBorderWidth,
          ),
          onTap: () => print("Drag onTap!"),
        )
      ],
    )
    

    stack mode

  • the second way: overlay mode

    _overlayEntry = OverlayEntry(builder: (context) {
      return DraggableFloatWidget(
        child: widget.child,
        eventStreamController: widget.eventStreamController,
        config: DraggableFloatWidgetBaseConfig(
          initPositionYInTop: false,
          initPositionYMarginBorder: 50,
          borderTopContainTopBar: true,
          borderBottom: widget.navigatorBarHeight + defaultBorderWidth,
        ),
        onTap: () => print("Drag onTap!"),
      );
    });
    
    /// Warning: context cannot be the context of MaterialApp
    Overlay.of(context)?.insert(_overlayEntry!);
    

    overlay mode

Contributions

If you encounter any problem or the library is missing a feature feel free to open an issue. Feel free to fork, improve the package and make pull request.

License

MIT

カテゴリー

ソースリポジトリ

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