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

パッケージ詳細v0.0.5+1

overlay_container

子要素を元のウィジェット階層の外にレンダリングするFlutterウィジェットです。

30日間ダウンロード
3
いいね数
50
Pub ポイント
40

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

flutter pub add overlay_container

パッケージ概要

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

OverlayContainer は、Flutter のウィジェットで、子要素を元のウィジェット階層の外にレンダリングし、親レイアウトとは無関係に要素を独立して配置できるようにします。これは、他のウィジェットの境界に縛られず、上部に表示される必要があるオーバーレイ、ツールチップ、またはフローティング UI コンポーネントを作成する場合に特に役立ちます。この動作は、Flutter の Overlay メカニズムを利用することで実現され、レイヤード UI 要素を効率的かつ明確に管理する方法を提供します。このパッケージは軽量でシンプルに設計されており、複雑なレイアウトでのウィジェット位置決めに対する正確なコントロールが必要な開発者にとって理想的です。

用途

  • フローティングアクションボタンの作成
  • ツールチップまたはポップオーバーの表示
  • カスタムモーダルダイアログの実装
  • オーバーレイメニューの作成
  • 親の制約を超えたUI要素の配置

主な機能

  • 親の階層外に子をレンダリング
  • 効率的なレンダリングのために Flutter の Overlay を使用します
  • 最小限のセットアップで簡単なAPI
  • 絶対配置をサポートします
  • 既存のウィジェットツリーとスムーズに連携します

適している対象

  • 高度なオーバーレイ機能を必要とする開発者
  • レイヤードインターフェースを実装するUIデザイナー
  • 動的なフローティング要素を必要とするプロジェクト
  • 複雑なインタラクティブオーバーレイを持つアプリ
  • クリーンで保守しやすいコードを重視するチーム

注意事項

  • フォーカスおよびジェスチャーの処理に注意が必要になる可能性があります
  • 静的レイアウト構造には適していません
  • 多数のオーバーレイによるパフォーマンスへの潜在的影響
  • オーバーレイエントリの適切な破棄が必要です
  • 制限されたプラットフォーム固有の最適化

元の README

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

overlay_container

Pub Package License

A flutter widget which renders its child outside the original widget hierarchy.

Demo.

Demo

This demo is present as an example here. You can also checkout the examples folder.

Description.

The child passed to this widget is rendered outside the widget hierarchy as an overlay to the exisiting widget tree. As a result this widget is highly suitable for building custom dropdown options, autocomplete suggestions, dialogs, etc. Think of it as widget placed absolutely and having a positive z-index over the rest of the widget tree. It is actually a friendly wrapper over the Flutter's Overlay and OverlayEntry APIs.

If you've ever used react, this tries to do what React Portal does, in a way.

Example.

import 'package:flutter/material.dart';
import 'package:overlay_container/overlay_container.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Overlay Container Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // Need to maintain a "show" state either locally or inside
  // a bloc.
  bool _dropdownShown = false;

  void _toggleDropdown() {
    setState(() {
      _dropdownShown = !_dropdownShown;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Overlay Container Demo Page'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            RaisedButton(
              onPressed: _toggleDropdown,
              child: Column(
                children: <Widget>[
                  Text("Dropdown button"),
                ],
              ),
            ),
            // By default the overlay (since this is a Column) will
            // be added right below the raised button
            // but outside the widget tree.
            // We can change that by supplying a "position".
            OverlayContainer(
              show: _dropdownShown,
              // Let's position this overlay to the right of the button.
              position: OverlayContainerPosition(
                // Left position.
                150,
                // Bottom position.
                45,
              ),
              // The content inside the overlay.
              child: Container(
                height: 70,
                padding: const EdgeInsets.all(20),
                margin: const EdgeInsets.only(top: 5),
                decoration: BoxDecoration(
                  color: Colors.white,
                  boxShadow: <BoxShadow>[
                    BoxShadow(
                      color: Colors.grey[300],
                      blurRadius: 3,
                      spreadRadius: 6,
                    )
                  ],
                ),
                child: Text("I render outside the \nwidget hierarchy."),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

A more elaborate example is found here.

Installation.

  • Instructions are here.

Inspiration

License.

カテゴリー

ソースリポジトリ

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

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