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

contextualactionbar 표지
패키지 상세v3.1.0

contextualactionbar

Flutter용 컨텍스트 액션 바(CAB) 대안. CAB은 앱 바를 대체하는 상단 앱 바로, 선택된 항목에 대한 컨텍스트 작업을 제공합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
119
좋아요
66
Pub 점수
150

패키지 설치

flutter pub add contextualactionbar

패키지 개요

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

contextualactionbar 패키지는 Flutter에서 컨텍스트 액션 바(CAB)를 구현하기 위한 대안을 제공하며, 항목이 선택되었을 때 표준 앱 바를 대체하는 동적 상단 앱 바를 가능하게 합니다. 안드로이드, iOS, 웹, macOS, Windows, 리눅스 등 여러 플랫폼에서 사용할 수 있도록 설계되어 선택 모드 중에 타겟 제어를 제공함으로써 사용자 인터랙션을 향상시킵니다. 기존의 Flutter 앱과 원활하게 통합되며, 사용자 정의 스타일 및 동작을 지원합니다. 특히 일괄 작업을 수행해야 하는 목록 또는 그리드 인터페이스에서 유용합니다.

사용 사례

  • 목록 내 배치 항목 선택
  • 그리드 내의 맥락 기반 작업
  • 모바일 앱에서 사용자 상호작용 향상
  • 사용자 정의 가능한 액션 오버레이
  • 크로스 플랫폼 구현
  • 선택 모드 UI 개선

주요 기능

  • 앱 바 동적 교체
  • 다중 플랫폼 지원
  • 사용자 정의 가능한 액션 버튼
  • 선택 모드와의 통합
  • 가볍고 구현하기 쉬움
  • 모든 기기용 반응형 디자인

적합한 대상

  • 인터랙티브 리스트 인터페이스를 구축하는 개발자
  • 배치 작업이 필요한 앱
  • 크로스 플랫폼 모바일 애플리케이션
  • 선택 기반 워크플로우를 갖춘 UI
  • 플랫폼에 관계없이 사용 가능한 CAB 솔루션을 찾는 팀
  • 컨텍스트 액션 지원이 필요한 플러터 프로젝트

고려 사항

  • 선택 상태를 수동으로 처리해야 합니다
  • 제한된 내장 애니메이션
  • 일관성을 위해 추가 스타일링이 필요할 수 있습니다
  • 스크롤 가능한 요소와의 적절한 통합에 의존
  • 간단한 정적 UI에 적합하지 않습니다
  • 상태 관리 패턴과 함께 사용할 때 가장 좋습니다

원본 README

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

Flutter contextual action bar(CAB)

CAB & Flutter

CAB is a top app bar that replace the application app bar to provide contextual actions to selected items. Check the material implementation and requirement here

Flutter does not natively support CAB yet. see issue Until CAB is natively supported, this package should provide you with an elegant way to implement the contextual action bar in flutter.

How it works

  • ContextualScaffold
  • ContextualAppBar
  • ContextualAction
  • ContextualActionWidget

ContextualScaffold<?>

The ContextualScaffold<?> is similar to the normal material Scaffold except that it also takes a required contextualAppBar.

ContextualScaffold<?>(
      contextualAppBar: ContextualAppBar(),
      appBar: AppBar(),
      body: Body(),
    )

You can provide multiple ContextualScaffold as needed

ContextualAppBar<?>

The ContextualAppBar<?> is similar to the normal material Appbar but takes a counterBuilder instead of title and also a contextualActions instead of actions.

 ContextualAppBar(
      counterBuilder: (int itemsCount){
        return Text("$itemsCount Selected");
      },
      contextualActions: <ContextualAction>[],
    )

ContextualAction<?>

The ContextualAction<?> allows you to take actions on the selected items, with the help of itemsHandler callback.

ContextualAction(
            itemsHandler: (List<?> items) {
              items.forEach((item) {
                Scaffold.of(context).showSnackBar(SnackBar(
                  content: Text("$item saved"),
                ));
              });
            },
            child: Icon(Icons.save),
          ),

ContextualActionWidget<?>

You can use the ContextualActionWidget anywhere in the ContextualActionScaffold body to notify ContextualActionScaffold that an item have been selected in order to show the ContextualAppBar.

   ContextualActionWidget(
          data: ?,
          child: ChildWidget(),
        )

Note: It is important that the child widget does not handle onLongPress.

A closer look at ContextualActionWidget<?>

The ContextualActionWidget<?> takes other optional parameters like

  • selectedColor
  • selectedWidget
  • unselectedWidget

The selectedColor is the color of the background for the selected item, it defaults to the splash color, if not provided. The selectedColor works well with ListTile.

selectedWidget and unselectedWidget are stacked on top of the provided child widget. By default, they are positioned at the center of the provided child widget. Since They are stacked, you can use Row, Align, Positioned Widget or any other combination of widgets to position them where desired.

The selectedWidget is shown when the ActionMode is enabled and the item is selected, while the unselectedWidget is shown when ActionMode is enabled and the item is not selected. See example(status_saver) image below with both the selectedWidget and unselectedWidget aligned to the top-right corner.

ActionMode

This contextual action bar workaround does not support zero item in the ActionMode.

  • Use the ActionMode.addItem<?> to add an item to the selected items. If this is the first selection, the ActionMode is will be enabled.

  • Use the ActionMode.addItems<?> to add a list of items.

  • Use the ActionMode.disable<?> to disable and deselect all selected items.

  • Use the ActionMode.enabledStream<?> to emit true or false depending on if the Action mode is enabled or disabled respectively.

Note: In most cases, you won't need to use ActionMode.disable<?> because the package already do that for you where needed.

Study complete examples at example page. If you like the project, don't forget to star ⭐️

Other Packages authored by me

License

This package is licensed under the MIT license. See LICENSE for details.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.