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

collapsible_sidebar 표지
패키지 상세v2.0.7

collapsible_sidebar

Material Design를 구현한 Flutter 앱용 접을 수 있는 사이드바입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2.4천
좋아요
370
Pub 점수
140

패키지 설치

flutter pub add collapsible_sidebar

패키지 개요

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

Material Design 지침에 부합하는 접을 수 있는 사이드바를 제공하는 플러터 패키지입니다. 전개 및 축소 상태 간의 부드러운 전환을 가능하게 하며, 반응형 앱에서 탐색에 이상적입니다. 사용자 정의 콘텐츠, 아이콘, 레이블 및 다중 플랫폼에서의 적응형 동작을 지원합니다. 공간 활용 효율성을 극대화하면서 직관적인 탐색을 유지해야 하는 앱용으로 설계되었습니다. 최소한의 설정으로 기존 플러터 프로젝트와 원활하게 통합됩니다.

사용 사례

  • 반응형 대시보드 인터페이스
  • 모바일 및 데스크톱 앱 탐색
  • 공간 효율적인 UI 레이아웃
  • Material Design 준수 사이드바
  • 다중 플랫폼 애플리케이션

주요 기능

  • Material Design 준수
  • 부드러운 전개/접기 애니메이션
  • 사용자 지정 가능한 콘텐츠 및 스타일
  • 크로스 플랫폼 지원 (Android, iOS, Web, macOS, Windows, Linux)
  • MaterialApp과의 간편한 통합

적합한 대상

  • 반응형 대시보드를 구축하는 개발자
  • 마테리얼 디자인 원칙을 따르는 팀
  • 적응형 탐색이 필요한 앱
  • 크로스 플랫폼 Flutter 프로젝트
  • UI 디자이너는 사용성 우선을 고려합니다

고려 사항

  • 최적의 표시를 위해 적절한 레이아웃 제약 조건이 필요합니다
  • 비-Material 테마에 대해 추가 스타일링이 필요할 수 있습니다
  • 매우 큰 콘텐츠 목록과 함께하는 성능 영향
  • 기본 구조를 넘어서는 사용자 정의가 제한적
  • 중간 수준의 탐색 항목을 가진 앱에 가장 적합

원본 README

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

collapsible_sidebar


A collapsible sidebar for Flutter apps implementing the Material Design.

responsive-ui

🌟 Version 2.0.7 ✨


Features

  • Material Design
  • Pre-built customizable tile widgets (CollapsibleItems)
  • Smooth Animation
  • Supports both LTR & RTL languages
  • Supports MULTI-LEVEL Menu
  • Alert Badges on CollapsibleItems

Supported platforms

  • Flutter Android
  • Flutter iOS
  • Flutter web
  • Flutter desktop

Contributors

A big thank you to all the contributors without whom this project would be impossible to maintain and enhance. 👏👏👏

Live preview

https://drunkonbytes.github.io/flutter_collapsible_sidebar

Note: this page is built with flutter-web. For a better user experience, please use a mobile device to open this link.

Installation

Add collapsible_sidebar: ^2.0.7 to your pubspec.yaml dependencies. And import it:

import 'package:collapsible_sidebar/collapsible_sidebar.dart';

How to use

  1. Create a list of CollapsibleItems named _items (or whatever fancy name you like)
For a collapsible item with sub-items to be the default selected item MARK ALL OF ITS SUB-ITEMS WITH THE isSelected: true property.
List<CollapsibleItem> get _items {
    return [
      CollapsibleItem(
          text: 'Shop',
          iconImage: AssetImage("assets/shop_icon.png"), //`iconImage` has priority over `icon` property
          icon: Icons.ac_unit,
          onPressed: () => setState(() => _headline = 'Shop'),
          onHold: () => ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(content: const Text("Shop"))
          ),
          isSelected: true,
          subItems: [
            CollapsibleItem(
              text: 'Cart',
              icon: Icons.shopping_cart,
              onPressed: () => setState(() => _headline = 'Cart'),
              onHold: () => ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: const Text("Cart"))
              ),
              isSelected: true,
            )
          ]
      ),
      CollapsibleItem(
        text: 'Dashboard',
        badgeCount: 7,
        icon: Icons.assessment,
        onPressed: () => setState(() => _headline = 'DashBoard'),
        onHold: () => ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: const Text("DashBoard"))
        ),
      ),
      CollapsibleItem(
        text: 'Ice-Cream',
        icon: Icons.icecream,
        onPressed: () => setState(() => _headline = 'Ice-Cream'),
        onHold: () => ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: const Text("Ice-Cream"))
        ),
      ),
      CollapsibleItem(
        text: 'Search',
        icon: Icons.search,
        onPressed: () => setState(() => _headline = 'Search'),
        onHold: () => ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: const Text("Search"))
        ),
      ),
    ];
  }
  1. Define the body of the app (the widget where the main working of the app will be) and name it say _body.
Widget _body(Size size, BuildContext context) {
    return Container(
      height: double.infinity,
      width: double.infinity,
      color: Colors.blueGrey[50],
      child: .........,
    );
  }
  1. Finally completely define the CollapsibleSidebar widget by adding the list of CollapsibleItems named _items, the body of the app named _body and the customizable parameters as needed:
CollapsibleSidebar(
  items: _items,
  avatarImg: _avatarImg,
  title: 'John Smith',
  body: _body(size, context),
)

Also you can use the isCollapsed condition depending how you want the state of the sidebar to change (collapsed/expanded) for example [size.width]

CollapsibleSidebar(
  isCollapsed: MediaQuery.of(context).size.width <= 800,
  items: _items,
  avatarImg: _avatarImg,
  title: 'John Smith',
  body: _body(size, context),
)

Parameters (customizable attributes)

Name Data Type Default Value Description
isCollapsed bool true can set condition to control state of sidebar (collapsed/expanded) on some property change
collapseOnBodyTap bool true flag to enable/disable tapping on the body of the app (area other than the sidebar) to collapse the sidebar
items List<CollapsibleItems> --- List of CollapsibleItems
showTitle bool true can set to false to hide title and avatar Image
title String --- Title of the Collapsible Sidebar
titleBack bool false set to 'true' to use a back icon instead of avatar picture
titleBackIcon Icons Icons.arrow_back the back icon is 'arrow_back' by default (customizable)
onTitleTap Function --- custom callback function called when title avatar or back icon is pressed
onHoverPointer SystemMouseCursors SystemMouseCursors.click the default hover mouse pointer is set to 'click' type by default (customizable)
textStyle TextStyle --- custom style for sidebar title
titleStyle TextStyle --- custom style for collapsible items text
toggleTitleStyle TextStyle --- custom style for toggle button title
avatarImg Image --- Image to be displayed
body Widget --- The main body of the app (the underlying main widget other than the sidebar)
height double double.infinity height of the Sidebar
minWidth double 80 Width of Sidebar when Collapsed
maxWidth double 270 Width of Sidebar when Expanded
borderRadius double 15 Radius of the borders
iconSize double 40 Size of the icons
customContentPaddingLeft double -1 Padding to the left of CollapsibleItems (keep value less than 0 for default padding)
toggleTitle String 'Collapse' title text of Toggle Button
toggleButtonIcon Icons Icons.chevron_right Icon of the Toggle button
backgroundColor Color Color(0xff2B3138) The background color
avatarBackgroundColor Color Color(0xff6A7886) The avatar background color
selectedIconBox Color Color(0xff2F4047) Color of Icon Box when selected
selectedIconColor Color Color(0xff4AC6EA) Color of Icon when selected
selectedTextColor Color Color(0xffF3F7F7) Color of text when selected
unselectedIconColor Color Color(0xff6A7886) Color of Icon when not selected
unselectedTextColor Color Color(0xffC0C7D0) Color of text when not selected
badgeBackgroundColor Color Color(0xffFF6767) Background color of badges on Collapsible Items
badgeTextColor Color Color(0xffF3F7F7) Badge Text color of badges on Collapsible Items
duration Duration Duration(milliseconds: 500) Animation duration for collapsed->expanded & vice-versa
curve Curves Curves.fastLinearToSlowEaseIn Animation curve for collapsed->expanded & vice-versa
screenPadding double 4 Padding to the screen
topPadding double 0 space between image avatar and icons
bottomPadding double 0 space between icons and toggle button
itemPadding double 10 space between collapsible items
customItemOffsetX double -1 X axis offset for collapsible items (keep value less than 0 for default offset)
fitItemsToBottom bool true fit all icons to the end of the space between image avatar and toggle button
showToggleButton bool true flag to enable/disable showing the toggle button
sidebarBoxShadow List<BoxShadow> [BoxShadow(color: Colors.blue, blurRadius: 10, spreadRadius: 0.01, offset: Offset(3, 3),),] Just like the "BoxDecoration" parameter of a "Container"

License


Apache 2.0

카테고리

소스 저장소

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