패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.0.5+1

overlay_container

자식 위젯을 원래 위젯 계층 구조 외부에 렌더링하는 플러터 위젯입니다.

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.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.