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

패키지 상세v0.1.2

flutter_anywhere_menus

어디서든 메뉴! 이제 부모 위젯이나 터치/클릭 위치에 따라 자동으로 배치되는 플로팅 메뉴를 만들 수 있습니다.

30일 다운로드
37
좋아요
36
Pub 점수
40

패키지 설치

flutter pub add flutter_anywhere_menus

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Flutter Anywhere Menus는 개발자가 부모 위젯 또는 사용자 터치/클릭 위치에 따라 동적으로 위치를 조정하는 플로팅 메뉴를 만들 수 있도록 해주는 가벼운 패키지입니다. 컨텍스트 민감한 작업에 이상적이며, 수동 위치 지정 없이도 메뉴가 필요한 곳에 정확히 나타나도록 하여 UI의 상호작용을 향상시킵니다. 이 패키지는 반응형 디자인을 지원하며 기존의 Flutter 앱에 원활하게 통합됩니다. 공간이 제한된 모바일 인터페이스에서 직관적인 탐색이 중요한 경우 특히 유용합니다.

사용 사례

  • 컨텍스트 액션 메뉴
  • 플로팅 팝업 메뉴
  • 터치 기반 메뉴 배치
  • 반응형 UI 컴포넌트
  • 모바일 앱 내비게이션 개선

주요 기능

  • 부모 또는 터치 기반 자동 위치 지정
  • 가볍고 쉽게 통합 가능
  • 동적 레이아웃 조정을 지원
  • 복잡한 구성이 필요하지 않습니다
  • 무결점의 플러터 호환성

적합한 대상

  • 모바일 앱 개발자
  • UI/UX 디자이너
  • 인터랙티브 인터페이스 빌더
  • 자주 사용되는 컨텍스트 작업을 가진 앱
  • 빠른 메뉴 솔루션을 찾는 개발자

고려 사항

  • Flutter 플랫폼에 제한됨
  • 내장 애니메이션 없음
  • 메뉴 항목 콜백을 수동으로 처리해야 합니다
  • 큰 메뉴 항목에 최적화되지 않음
  • 위치 지정을 위해 올바른 위젯 계층 구조에 의존

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Anywhere Menus (FAM) Pub Version

Menus, anywhere you want them!

Default Usage

Imgur

Menu(
  child: MaterialButton(
    child: Text('Show Basic Menu'),
  ),
  menuBar: MenuBar(),
),

Slightly Fancier Menu

Imgur

Menu(
  child: MaterialButton(
    child: Text('Dem Fancy Menus'),
  ),
  menuBar: MenuBar(
    drawArrow: true,
    itemPadding: EdgeInsets.symmetric(horizontal: 15, vertical: 4),
    menuItems: [
      MenuItem(
        child: Icon(Icons.color_lens, color: Colors.grey[600]),
        onTap: () => _incrementCounter(),
      ),
      MenuItem(
        child: Menu(
          offset: Offset(0, 20),
          child: Icon(Icons.colorize, color: Colors.grey[600]),
          menuBar: MenuBar(
              drawArrow: true,
              drawDivider: true,
              maxThickness: 68,
              orientation: MenuOrientation.vertical,
              menuItems: [MenuItem(child: Icon(Icons.add))]),
        ),
      ),
      MenuItem(
          child: Icon(Icons.content_copy, color: Colors.grey[600])),
    ],
  ),
),

Menu On Tap

Imgur

Menu(
  tapType: TapType.tap,
  child: Container(
    width: 300,
    height: 200,
    color: Colors.yellow,
    child: Center(child: Text('Show Menu Over Tap')),
  ),
  menuOverTap: true,
  menuBar: menuBar,
),

Roadmap

  • [x] Vertical menus
  • [ ] Animations
  • [ ] Fixed screen position menus (Guess that'd just be a Toast...)

Background

Why FAM? The short answer is... yak shaving. I needed a menu for a project that would pop up above a widget when I clicked on it. Simple right? Yeah... no. There were a few more requirements that made it a far more interesting problem.

  1. The menu needs to be very customizable
  2. The menu needs the ability to have child menus OR child widgets
  3. The menu (and all children) needs to be a drawn above all other widgets
  4. And this was the doozy... the menu needs to be positionable RELATIVE to its parent widget, and all child menus and child widgets need to be relative positioned to their parent

That last requirement took me down the rabbit hole of Flutter widget positioning and long story short, Flutter is one of a few (maybe the only?) rendering/UI languages I've used that simply cannot do relative positioning out of the box (pun intended). See, the box is what traps you. You can Column() and Row() all day long but you're still trapped in box. What I want is the equivalent of widget1.alignTo(widget2, fromAlignment: Alignment.topCenter, toAlignment: Alignment.bottomCenter) so that I can setup a widget and then just stick it on to another widget. A man can dream right?

Maybe Stack() and Align()? HA! Still stuck in that box, and still no way to define a solid widget-to-widget positioning.

I want my menu outside of the box MAN! And without knowing the sizes of the boxes before rendering, good luck trying to accurately position a menu over (or under, or next to) its intended target widget. So what does FAM do?

It... cheats.

FAM still doesn't know about the properties of the menu before hand, BUT what it can do is render the menu invisibly as an overlay, examine its size, then move it to where it needs to be. The result is that I can now define an absolute relationship between relevant points on a widget (say, tying the bottomCenter of one widget to the topCenter of another) without either widget having any relationship, and without any restrictions on how I draw either widget, while making sure that whatever crazy alignments I do won't mess up the positioning or size of my original widget.

OK. It ain't pretty, but the results do speak for themselves. Hope at least some of you can make use of this, and maybe Flutter will one day have relational positioning like any sensible rendering language.

Credits

This was originally a fork of https://github.com/CaiJingLong/flutter_long_tap_menu that outgrew most of the original code. Many yak were shaved in the process.

카테고리

소스 저장소

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

아직 데이터가 없습니다.