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

star_menu 표지
패키지 상세v4.0.2

star_menu

다양한 모양의 컨텍스트 팝업 메뉴와 애니메이션 및 위치를 세밀하게 조정할 수 있는 다양한 방법을 제공합니다. 메뉴 항목은 거의 모든 종류의 위젯일 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.9천
좋아요
234
Pub 점수
150

패키지 설치

flutter pub add star_menu

패키지 개요

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

스타 메뉴는 다양한 형태, 정밀한 애니메이션 제어 및 유연한 위치 지정을 지원하는 사용자 정의 가능한 컨텍스트 팝업 메뉴를 제공하는 플러터 패키지입니다. 개발자는 거의 모든 위젯을 메뉴 항목으로 배치할 수 있어 풍부한 인터랙티브 디자인을 가능하게 합니다. 여러 플랫폼에서 직관적이고 시각적으로 매력적인 메뉴를 만들기에 적합하며, 부드러운 전환과 동적 레이아웃을 통해 사용자 경험을 향상시킵니다. 문서화가 잘 되어 있으며 지속적으로 유지 관리되고 있어 기존 프로젝트에 쉽게 통합할 수 있습니다.

사용 사례

  • 모바일 앱에서 사용자 정의 컨텍스트 메뉴
  • 애니메이션 효과가 있는 상호작용 UI 요소
  • 크로스 플랫폼 메뉴 구현
  • 시각 피드백을 제공하는 개선된 탐색
  • 동적 위젯 기반 메뉴 항목

주요 기능

  • 사용자 정의 모양의 메뉴 지원
  • 세밀한 애니메이션 사용자 정의
  • 유연한 위치 지정 옵션
  • 모든 위젯을 메뉴 항목으로 사용할 수 있는 호환성
  • 다중 플랫폼 지원 (Android, iOS, Web, macOS, Windows, Linux)
  • pub.dev를 통한 간편한 통합

적합한 대상

  • 인터랙티브한 Flutter 애플리케이션을 개발하는 개발자
  • 고급 메뉴 애니메이션을 찾는 디자이너
  • 일관된 UI를 갖춘 여러 플랫폼을 타겟으로 하는 팀
  • 맥락 기반의 즉시 메뉴가 필요한 앱
  • 시각적 완성도와 사용자 참여를 강조하는 프로젝트

고려 사항

  • 복잡한 레이아웃을 위해 추가 스타일링이 필요할 수 있습니다
  • 대량의 메뉴 항목으로 인한 성능 영향
  • 고급 애니메이션 설정의 학습 곡선
  • 간단한 정적 메뉴에는 적합하지 않습니다
  • 복잡한 위젯에서 컨텍스트와 위치를 신중하게 다뤄야 합니다

원본 README

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

StarMenu
Easy and Fast Way to build Context Menus

Pub Version Pub Likes Pub Likes Pub Likes GitHub repo size GitHub forks GitHub stars GitHub license

pub.dev link

Image

Instead, a star would be wonderful! ;)

A simple way to attach a popup menu to any widget with any widget as menu entries. Menu entry widgets can bind a sub-menu with different shapes. Multiple ways to fine-tune animation and position.

Image Image

Every widgets can be tapped to display a popup menu! There are currently 3 shapes to choose:

  • linear: items are lined by a given angle with a given space between them and with a 3-way alignment.
  • circle: items are lined up in a circle shape with a given radius and a star-end angle.
  • grid: items are aligned in a grid shape with N columns and a given horizontal and vertical space.
Image Image Image
linear circle panel

Please take a look at main.dart and main_more.dart in the example/lib dir for the examples.

Using the package is pretty simple:

  • install the package with flutter pub add star_menu
  • feed the items parameter with the menu entry widgets list
  • set the params with StarMenuParameters
  • set the child with a widget you wish to press to open the menu
StarMenu(
  params: StarMenuParameters(),
  onStateChanged: (state) => print('State changed: $state'),
  onItemTapped: (index, controller) {
    // here you can programmatically close the menu
    if (index == 7)
      controller.closeMenu();
	print('Menu item $index tapped');
  }),
  items: entries,
  child: FloatingActionButton(
    onPressed: () {print('FloatingActionButton tapped');},
    child: Icon(Icons.looks_one),
  ),
)
  • onStateChanged triggers menu state canges:
enum MenuState {
  closed,
  closing,
  opening,
  open,
}
  • items parameter is used when entries are known. If you want to build items in runtime use lazyItems, ie when StarMenu is already builded in the widget tree, but the menu items changed:
StarMenu(
  ...
  lazyItems: () async{
      return [
        Container(
          color: Color.fromARGB(255, Random().nextInt(255),
              Random().nextInt(255), Random().nextInt(255)),
          width: 60,
          height: 40,
          child: Text(userName),
        ),
        ...
      ];
  }
)

lazyItems is a callback function which returns Future<List<Widget>> which is called before opening the menu. Only lazyItems or items can be used.

StarMenu can be created also with addStarMenu() widget extension:

FloatingActionButton(
  onPressed: () {print('FloatingActionButton tapped');},
  child: Icon(Icons.looks_one),
).addStarMenu(
  items: items,
  params: StarMenuParameters(),
  controller: controller,
  onItemTapped: (index, controller) {}),


Programmatically open menu

There are two ways to programmatically open a menu, for example when pressing a button:

  • if you already have a StarMenu in the tree, add [StarMenuController] to it:
  StarMenuController starMenuController = StarMenuController();

  StarMenu(
    params: StarMenuParameters(),
    controller: starMenuController,
    items: entries,
    child: ...,
  )

then in your button:

ElevatedButton(
  onPressed: () => starMenuController.openMenu!(),
  child: ...,
),
  • if you want to dinamically create a StartMenu for another widget, assign a GlobalKey to your widget:
GlobalKey containerKey = GlobalKey();
...
Container(
  key: containerKey,
  width: 40,
  height: 40,
),

then in your button call StarMenuOverlay.displayStarMenu with the widget context:

ElevatedButton(
  onPressed: () {
    StarMenuOverlay.displayStarMenu(
      containerKey.currentContext!,
      StarMenu(
        params: StarMenuParameters(),
        items: entries,
        parentContext: containerKey.currentContext,
      ),
    );
  },
  child: ...
),
StarMenu

Only [items] or [lazyItems] can be passed, not both.

Name Type Defaults Description
params class StarMenuParameters See below.
items List? - Widget items entry list.
lazyItems Future<List> Function()? - Function to build dynamically items list whenever the menu open occurs.
child Widget - Widget that triggers the opening of the menu. Only [child] or [parentContext] is allowed
parentContext BuildContext - Widget that triggers the opening of the menu. Only [child] or [parentContext] is allowed
controller StarMenuController - context of the Widget where the menu will be opened. Only [child] or [parentContext] is allowed
onStateChanged Function(MenuState state)? - Return current menu state.
StarMenuParameters

Class to define all the parameters for the shape, animation and menu behavior.

Name Type Defaults Description
shape enum MenuShape.circle Menu shape kind. Could be [MenuShape.circle], [MenuShape.linear], [MenuShape.grid].
boundaryBackground class - See below.
linearShapeParams class - See below.
circleShapeParams class - See below.
gridShapeParams class - See below.
backgroundParams class - See below.
openDurationMs int 400 Open animation duration ms.
closeDurationMs int 150 Close animation duration ms.
rotateItemsAnimationAngle double 0.0 Starting rotation angle of the items that will reach 0 DEG when animation ends.
startItemScaleAnimation double 0.3 Starting scale of the items that will reach 1 when animation ends.
centerOffset Offset Offset.zero Shift offset of menu center from the center of parent widget.
useScreenCenter bool false Use the screen center instead of parent widget center.
useTouchAsCenter bool false Use the touch coordinate as the menu center.
checkItemsScreenBoundaries bool false Checks if the whole menu boundaries exceed screen edges, if so set it in place to be all visible.
checkMenuScreenBoundaries bool true Checks if items exceed screen edges, if so set them in place to be visible.
animationCurve Curve Curves.fastOutSlowIn Animation curve kind to use.
useLongPress bool false Use long press instead of a tap to open the menu.
longPressDuration Duration 500 ms The timing to trigger long press.
onHoverScale double 1.0 Scale item when mouse is hover (desktop only)

There are some StarMenuParameters factory presets with which you can set StarMenu.params

StarMenuParameters.dropdown(BuildContext context) Image
StarMenuParameters.panel(BuildContext context, {int columns = 3}) Image

StarMenuParameters.arc(BuildContext context, ArcType type, {double radiusX = 130, double radiusY = 130})

type result
ArcType.semiUp Image
ArcType.semiDown Image
ArcType.semiLeft Image
ArcType.semiRight Image
ArcType.quarterTopRight Image
ArcType.quarterTopLeft Image
ArcType.quarterBottomRight Image
ArcType.quarterBottomLeft Image

BoundaryBackground
Name Type Defaults Description
color Color 0x80000000 color of the boundary background.
padding EdgeInsets EdgeInsets.all(8.0) Padding of the boundary background.
decoration Decoration BorderRadius.circular(8) background Container widget decoration.
blurSigmaX double 0.0 horizontal blur of the boundary background.
blurSigmaY double 0.0 vertical blur of the boundary background.

LinearShapeParams
Name Type Defaults Description
angle double 90.0 Degree angle. Anticlockwise with 0° on 3 o'clock.
space double 0.0 Space between items.
alignment LinearAlignment center left, center, right, top, bottom. Useful when the linear shape is vertical or horizontal.

CircleShapeParams
Name Type Defaults Description
radiusX double 100.0 Horizontal radius.
radiusY double 100.0 Vertical radius.
startAngle double 0.0 Starting angle for the 1st item. Anticlockwise with 0° on the right.
endAngle double 360.0 Ending angle for the 1st item. Anticlockwise with 0° on the right.

GridShapeParams
Name Type Defaults Description
columns int 3 Number of columns.
columnsSpaceH int 0 Horizontal space between items.
columnsSpaceV int 0 Vertical space between items.

BackgroundParams
Name Type Defaults Description
animatedBlur bool false Animate background blur from 0.0 to sigma if true.
sigmaX double 0.0 Horizontal blur.
sigmaY double 0.0 Vertical blur.
animatedBackgroundColor bool false If true animate from transparent to [backgroundColor].
backgroundColor Color Colors.transparent Background color.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.