A collapsible sidebar for Flutter apps implementing the Material Design.

Overview

collapsible_sidebar


A collapsible sidebar for Flutter apps implementing the Material Design.

indicator

Features

  • Material Design
  • Pre-built customizable tile widgets (CollapsibleItems)
  • Smooth Animation

Supported platforms

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

🌟 Version 2.0.1+2


  • Added ability to handle lists of icons
  • Added ability to apply bottom and top padding to List of icons
  • Added ability to choose direction of icon tiles (top/bottom) using fitItemsToBottom property.
  • Added ability to give custom name to toggle button
  • Added ability to give custom Style to sidebar title using titleStyle property.
  • Added ability to give custom Style to collapsible items text using textStyle property.
  • Added ability to give custom Style to toggle button title using toggleTitleStyle property.
  • Added support for Null-Safety. (By José Luis)
  • Added Mouse Region Detection on Web and ability to change Cursor type. (By TheLonelyNull)
  • Title Avatar picture can be replaced with custom back icon. (By TheLonelyNull)
  • Title Avatar clickable with custom callback function. (By TheLonelyNull)
  • Added ability to set Sidebar Collapsed or Expanded initially by changing the isCollapsed parameter.
  • Added ability to set custom BoxShadows to the sidebar using the sidebarBoxShadow parameter.

Live preview

https://ryuukenshi.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.1+2 to your pubspec.yaml dependencies. And import it:

import 'package:collapsible_sidebar/collapsible_sidebar.dart';

How to use

Simply create a CollapsibleSidebar widget and a list of CollapsibleItems suppose _items. Finally add the required parameters to CollapsibleSidebar and a body widget suppose _body which will occupy the remaining screen:

CollapsibleSidebar(
  items: _items,
  avatarImg: _avatarImg,
  title: 'John Smith',
  body: _body,
)

Parameters

CollapsibleSidebar(
    isCollapsed: true, //true by default, set to 'false' to have the full sidebar open on initially loading the app
    items: _items,
    title: 'Lorem Ipsum',
    titleBack: false,  //false by default, set to 'true' to use a back icon instead of avatar picture
    titleBackIcon: Icons.arrow_back, //the back icon is 'arrow_back' by default (customizable)
    onTitleTap: () {  //custom callback function called when title avatar or back icon is pressed
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('Yay! Flutter Collapsible Sidebar!')));
    },
    onHoverPointer: SystemMouseCursors.click, //the default hover mouse pointer is set to 'click' type by default (customizable)
    textStyle: TextStyle(fontSize: 20), //custom style for sidebar title
    titleStyle: TextStyle(fontSize: 20), //custom style for collapsible items text
    toggleTitleStyle: TextStyle(fontSize: 20), //custom style for toggle button title
    avatarImg: NetworkImage('https://www.w3schools.com/howto/img_avatar.png'),
    body: _body,
    height: double.infinity,
    minWidth: 80,
    maxWidth: 270,
    borderRadius: 15,
    iconSize: 40,
    toggleTitle: 'Collapse', //title text of Toggle Button
    toggleButtonIcon: Icons.chevron_right,
    backgroundColor: Color(0xff2B3138),
    selectedIconBox: Color(0xff2F4047),
    selectedIconColor: Color(0xff4AC6EA),
    selectedTextColor: Color(0xffF3F7F7),
    unselectedIconColor: Color(0xff6A7886),
    unselectedTextColor: Color(0xffC0C7D0),
    duration: Duration(milliseconds: 500),
    curve: Curves.fastLinearToSlowEaseIn,
    screenPadding: 4,
    topPadding: 0, //space between image avatar and icons
    bottomPadding: 0, //space between icons and toggle button
    fitItemsToBottom: true, //fit all icons to the end of the space between image avatar and toggle button
    showToggleButton: true,
    sidebarBoxShadow: [BoxShadow(
                            color: Colors.blue,
                            blurRadius: 10,
                            spreadRadius: 0.01,
                            offset: Offset(3, 3),
                          ),],
     //sidebarBoxShadow accepts a list
   
     just like the "BoxDecoration" parameter of a "Container". By default a black shadow is applied.
   
)

License


Apache 2.0

Comments
  • Change TextStyle Issue.

    Change TextStyle Issue.

    @RyuuKenshi How to change TextStyle in Menu?

    Code :

    CollapsibleSidebar( items: _items, avatarImg: NetworkImage('https://www.w3schools.com/howto/img_avatar.png'), title: 'Test', iconSize: 25.0, textSize: 15.0, minWidth: 67.0, height: double.infinity, duration: Duration(milliseconds: 500), curve: Curves.fastLinearToSlowEaseIn, toggleButtonIcon: Icons.arrow_forward_ios, screenPadding: 4, borderRadius: 15, body: _body(size, context), ),

    opened by DipakSkywave 3
  • Scrolling menu for multiple tabs

    Scrolling menu for multiple tabs

    When you add multiple items to the list you get pixels overflow error I made a little change here :

    https://github.com/RyuuKenshi/flutter_collapsible_sidebar/blob/00f5e8fa929ea05e5dcc9da3362e59f7a90ca278/lib/collapsible_sidebar.dart#L172-L184

    So now it looks like

                        Stack(
                          children: [
                            /**
                            CollapsibleItemSelection(
                              height: _maxOffsetY,
                              offsetY: _maxOffsetY * _selectedItemIndex,
                              color: widget.selectedIconBox,
                              duration: widget.duration,
                              curve: widget.curve,
                            ),*/
    
                            ConstrainedBox(
                              constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height / 3),
                              child: ListView.builder(
                              itemCount: _items.length,
                              shrinkWrap: true,
                              itemBuilder: (BuildContext context, int index) {
                              return _items[index];
                              }
                              ),
                            ),
                          ],
                        ),
    

    I commented the selected item highlighting because it doesn't scroll with the list so if you have better answers that would be great !

    opened by Hijodelalunah 3
  • Collapse text changeable?

    Collapse text changeable?

    Is it possible to change the "Collapse" text in the expanded sidebar (needed for localization) ?

    And is it possible to have an option to specifiy expanded mode as default and/or to programmably change the current mode?

    opened by PsychTechApS 3
  • Add mouse pointer changes and hover underline for web

    Add mouse pointer changes and hover underline for web

    On Web the mouse pointer was not changing when entering a collapsible item. I have added a mouse area to detect that and also underline text on hover.

    opened by TheLonelyNull 1
  • LateInitializationError: Field '_selectedItemIndex@25278355' has not been initialized.

    LateInitializationError: Field '_selectedItemIndex@25278355' has not been initialized.

    ════════ Exception caught by widgets library ═══════════════════════════════════
    The following LateError was thrown building CollapsibleSidebar(
    dirty, dependencies: [_EffectiveTickerMode], state: 
    _CollapsibleSidebarState#b9f65(ticker inactive)):
    
    LateInitializationError: Field '_selectedItemIndex@25278355' has not been initialized.
    
    

    This error is related to null safety and late initialization of _selectedItemIndex parameter.

    opened by prateekmedia 1
Owner
Arjun Sinha
A crazy programmer with ginormous DREAMS.
Arjun Sinha
Flutter widgets and themes implementing the current macOS design language.

macos_ui Flutter widgets and themes implementing the current macOS design language. NOTE: This package depends on the excellent native_context_menu pl

Reuben Turner 1.1k Jan 7, 2023
Material io ext - A collection of extensions for creating widgets following material.io guidelines

material_io_ext It is a collection of extensions for creating widgets following

null 3 Jan 28, 2022
A draggable Flutter widget that makes implementing a Sliding up and fully-stretchable much easier.

Draggable Home A draggable Flutter widget that makes implementing a Sliding up and fully-stretchable much easier! Based on the Scaffold and Sliver. Us

Devs On Flutter 106 Dec 12, 2022
Customizable Material and Cupertino buttons with progress indicators and more

future_button Customizable Material and Cupertino buttons with progress indicators and more.

Erzhan 33 Oct 13, 2022
Love the material AppBar? Do you want to add more color to the appbar? Here's a gradientAppBar.

Gradient App Bar Love the material AppBar? Do you want to add more color to the appbar? Here's a gradientAppBar. It works just like the normal AppBar.

Joost Lekkerkerker 131 Nov 11, 2022
Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget

lite_rolling_switch Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget https://github.com/pedromas

Eduardo Muñoz 48 Dec 1, 2022
Unofficial search provider for Medium for dart/flutter apps.

medium_search Unofficial search provider for Medium that can be used in dart or flutter apps. This library provides you an easy way to get search resu

Clone Conflict 1 Jan 10, 2022
Pick colors from pixels of everything visible in your Flutter apps

pixel_color_picker A widget that extracts colors from its childs. This package lets you basically extract colors from everything in your screen.

Eleandro Duzentos 14 Oct 17, 2022
Fancy design of radio buttons in Flutter (package).

A Flutter package for new radio button design. With Elegant Animation. Features Usage TODO: Include short and useful examples for package users. Add l

Aymen Boucheffa 0 Nov 26, 2021
Expanded Widget Advanced Design For Flutter

app_bar A new Flutter project. Getting Started This project is a starting point

HredayTheDev 0 Jan 16, 2022
This clock face was inspired by neumorphic design.

Flutter Clock This clock face was inspired by neumorphic design. The main goal during development was simplicity and attention to details. Clock face'

Dominik Roszkowski 94 Dec 9, 2022
A popup simple topModalSheet menu button widget with handsome design and easy to use

top_modal_sheet A popup simple topModalSheet menu button widget with handsome design and easy to use. Installations Add top_modal_sheet: ^1.0.0 in you

Baldemar Alejandres 5 Jul 29, 2022
Making-form - A form design with dart programming and auto next facility

Making-form - A form design with dart programming and auto next facility

Munem Sarker 3 Nov 15, 2022
Flutter package: Assorted layout widgets that boldly go where no native Flutter widgets have gone before.

assorted_layout_widgets I will slowly but surely add interesting widgets, classes and methods to this package. Despite the package name, they are not

Marcelo Glasberg 122 Dec 22, 2022
Flutter Carousel Pro - A Flutter Carousel widget

Carousel Extended A Flutter Carousel widget. Usage As simple as using any flutter Widget. Based on Carousel Pro but extended to be able to navigate be

omid habibi 3 Dec 7, 2020
Flutter-useful-widgets - Flutter Useful Widgets

useful_widgets This package makes it easy to build apps by providing a list of simple and useful widgets. import 'package:useful_widgets/useful_widget

Ricardo Crescenti 6 Jun 20, 2022
Flutter Duration Button - Create auto-click button likes Netflix's Skip Intro button in Flutter

Flutter Duration Button - Create auto-click button likes Netflix's Skip Intro button in Flutter

Kim Seung Hwan 7 Dec 7, 2022
Various Flutter widgets that are developed by Google but not by the core Flutter team

Flutter widgets This repository contains the source code for various Flutter widgets that are developed by Google but not by the core Flutter team. Is

Google 1.1k Jan 7, 2023
🟥 A flutter widget that flashes when flutter fails to render a frame in a certain timeframe

?? A flutter widget that flashes when flutter fails to render a frame in a certain timeframe

Andrei Lesnitsky 32 Oct 8, 2022