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

flutter_expandable_fab 표지
패키지 상세v3.0.0

flutter_expandable_fab

여러 작업 버튼의 표시 및 숨김을 애니메이션화할 수 있는 플로팅 액션 버튼(FAB) 스피드 다이얼.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.2만
좋아요
448
Pub 점수
160

패키지 설치

flutter pub add flutter_expandable_fab

패키지 개요

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

애니메이션 속도 다이얼 플로팅 액션 버튼(FAB)을 제공하는 플러터 패키지로, 사용자가 부드러운 전환 효과를 통해 여러 작업 버튼을 확장하고 축소할 수 있습니다. 단일 FAB에서 여러 작업에 접근할 수 있는 컴팩트하고 제스처 기반의 방식을 제공함으로써 UI의 상호작용성을 향상시킵니다. 이 패키지는 모든 주요 플랫폼을 지원하며 모바일 및 웹 애플리케이션에서 직관적인 탐색을 위해 설계되었습니다. 사용자 정의 가능한 애니메이션과 위치 설정은 현대적이고 동적인 인터페이스에 적합합니다.

사용 사례

  • 여러 작업을 포함한 하단 탐색
  • 컨텍스트 작업 메뉴
  • 모바일 앱을 위한 향상된 사용자 인터페이스
  • 일반적인 기능에 대한 빠른 액세스
  • 웹에서의 인터랙티브 디자인 요소
  • 생산성 앱에서의 원활한 워크플로우

주요 기능

  • 부드러운 전개/접기 애니메이션
  • 사용자 정의 가능한 버튼 위치
  • 다중 액션 항목 지원
  • 크로스 플랫폼 호환성
  • 기존 UI와의 간편한 통합
  • 사용자 정의 가능한 애니메이션 지속 시간 및 곡선

적합한 대상

  • 인터랙티브 모바일 앱을 개발하는 개발자
  • 동적 FAB 솔루션을 찾는 디자이너
  • 크로스 플랫폼 프로젝트에 플러터를 사용하는 팀
  • 컨텍스트 액션 패널이 필요한 앱
  • 사용자 경험 중심의 애플리케이션 개발
  • 제스처 기반 상호작용에 중점을 둔 프로젝트

고려 사항

  • 많은 액션 버튼이 있을 경우 성능에 영향을 미칠 수 있습니다
  • 신중한 레이아웃 계획이 필요합니다
  • 애니메이션 동작은 플랫폼에 따라 달라질 수 있습니다
  • 간단한 단일 작업 시나리오에 적합하지 않음
  • 모든 대상 플랫폼에서 테스트 필요
  • 기본 스타일링을 넘어서는 사용자 정의가 제한적

원본 README

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

flutter_expandable_fab

pub package

English, 日本語

flutter_expandable_fab is a speed dial FAB (Floating Action Button) that can animate the display and hiding of multiple action buttons.
It can be configured to display vertically, horizontally, or in a fan-shaped manner, on either side. It allows for fine-grained customization.

Migration from 1.x to 2.x

In version 2.x, I have made changes to enable free customization of the open/close buttons by setting builders.

Code before migration:
ExpandableFab(
  child: const Icon(Icons.account_box),
  foregroundColor: Colors.amber,
  backgroundColor: Colors.green,
  closeButtonStyle: const ExpandableFabCloseButtonStyle(
    child: Icon(Icons.abc),
    foregroundColor: Colors.deepOrangeAccent,
    backgroundColor: Colors.lightGreen,
  )
  expandedFabSize: ExpandedFabSize.small,
  collapsedFabSize: ExpandableFabSize.regular,
  expandedFabShape: const CircleBorder(),
  collapsedFabShape: const CircleBorder(),
)
Code after migration:
ExpandableFab(
  openButtonBuilder: RotateFloatingActionButtonBuilder(
    child: const Icon(Icons.account_box),
    fabSize: ExpandableFabSize.regular,
    foregroundColor: Colors.amber,
    backgroundColor: Colors.green,
    shape: const CircleBorder(),
  ),
  closeButtonBuilder: DefaultFloatingActionButtonBuilder(
    child: const Icon(Icons.close),
    fabSize: ExpandableFabSize.small,
    foregroundColor: Colors.deepOrangeAccent,
    backgroundColor: Colors.lightGreen,
    shape: const CircleBorder(),
  ),
)

Showcase

Fan style & Blur overlay
Vertical style & Color overlay
Horizontal style & Custom buttons
Center Fan style
floatingActionButton: ExpandableFab(
  type: ExpandableFabType.fan,
  pos: ExpandableFabPos.center,
  fanAngle: 180,

Getting started

import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';

Scaffold(
  floatingActionButtonLocation: ExpandableFab.location,
  floatingActionButton: ExpandableFab(
    children: [
      FloatingActionButton.small(
        heroTag: null,
        child: const Icon(Icons.edit),
        onPressed: () {},
      ),
      FloatingActionButton.small(
        heroTag: null,
        child: const Icon(Icons.search),
        onPressed: () {},
      ),
    ],
  ),
),

Open/Close programmatically

class _FirstPageState extends State<FirstPage> {
  final _key = GlobalKey<ExpandableFabState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButtonLocation: ExpandableFab.location,
      floatingActionButton: ExpandableFab(
        key: _key,
        children: [
          FloatingActionButton.small(
            child: const Icon(Icons.edit),
            onPressed: () {
              final state = _key.currentState;
              if (state != null) {
                debugPrint('isOpen:${state.isOpen}');
                state.toggle();
              }
            },
          ),
        ],
      ),
    );
  }
}

Customize

You can customize the open/close buttons with your preferred Widget using FloatingActionButtonBuilder. By using DefaultFloatingActionButtonBuilder, you can easily set up the FloatingActionButton. RotateFloatingActionButtonBuilder provides a FloatingActionButton with a rotating animation. Also, the items specified in children don't necessarily have to be FloatingActionButton; you can set any Widget freely.

ExpandableFab(
  openButtonBuilder: RotateFloatingActionButtonBuilder(
    child: const Icon(Icons.account_box),
    fabSize: ExpandableFabSize.regular,
    foregroundColor: Colors.amber,
    backgroundColor: Colors.green,
    shape: const CircleBorder(),
  ),
  closeButtonBuilder: FloatingActionButtonBuilder(
    size: 56,
    builder: (BuildContext context, void Function()? onPressed,
        Animation<double> progress) {
      return IconButton(
        onPressed: onPressed,
        icon: const Icon(
          Icons.check_circle_outline,
          size: 40,
        ),
      );
    },
  ),
  children: [
    FloatingActionButton.large(
      heroTag: null,
      child: const Icon(Icons.edit),
      onPressed: () {},
    ),
    IconButton(
      onPressed: () {
        final state = _key.currentState;
        if (state != null) {
          debugPrint('isOpen:${state.isOpen}');
          state.toggle();
        }
      },
      icon: const Icon(
        Icons.share,
        size: 30,
      ),
    ),
  ],
)

Since children is an array of widgets, you can place any widget you like, not limited to FloatingActionButton.
You can also create buttons with labels as shown below.

floatingActionButton: ExpandableFab(
  key: _key,
  type: ExpandableFabType.up,
  childrenAnimation: ExpandableFabAnimation.none,
  distance: 70,
  overlayStyle: ExpandableFabOverlayStyle(
    color: Colors.white.withOpacity(0.9),
  ),
  children: const [
    Row(
      children: [
        Text('Remind'),
        SizedBox(width: 20),
        FloatingActionButton.small(
          heroTag: null,
          onPressed: null,
          child: Icon(Icons.notifications),
        ),
      ],
    ),
    Row(
      children: [
        Text('Email'),
        SizedBox(width: 20),
        FloatingActionButton.small(
          heroTag: null,
          onPressed: null,
          child: Icon(Icons.email),
        ),
      ],
    ),
    Row(
      children: [
        Text('Star'),
        SizedBox(width: 20),
        FloatingActionButton.small(
          heroTag: null,
          onPressed: null,
          child: Icon(Icons.star),
        ),
      ],
    ),
    FloatingActionButton.small(
      heroTag: null,
      onPressed: null,
      child: Icon(Icons.add),
    ),
  ],
),

Properties

ExpandableFab
Property Description Default
distance Distance from children 100
duration Animation duration 250ms
fanAngle Angle of opening when fan type 90
initialOpen Open at initial display false
type The type of behavior of this widget fan
pos Position for displaying the widget right
closeButtonBuilder Builder for the close button
openButtonBuilder Builder for the open button
childrenOffset For positioning of children widgets
childrenAnimation Types of animations for Children rotate
children The widgets below this widget in the tree
onOpen Will be called before opening the menu
afterOpen Will be called after opening the menu
onClose Will be called before the menu closes
afterClose Will be called after the menu closes
overlayStyle Provides the style for overlay. No overlay when null.
openCloseStackAlignment Defines how [openButtonBuilder] and [closeButtonBuilder] are aligned in a [Stack] Alignment.center
FloatingActionButtonBuilder
Property Description Default
builder Callback to build the Widget
size Size of the Widget
DefaultFloatingActionButtonBuilder
Property Description Default
fabSize Size of the button regular
foregroundColor Foreground color of the button
backgroundColor Background color of the button
shape Shape of the close button
heroTag Tag to apply to the [Hero] widget of the button
child Child widget of the button
RotateFloatingActionButtonBuilder
Property Description Default
angle Angle of rotation (in radians) math.pi / 2
... Same as DefaultFloatingActionButtonBuilder

Thanks

I referred to the code from this article: https://docs.flutter.dev/cookbook/effects/expandable-fab

카테고리

의존성

의존성 목록 1 개

소스 저장소

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