Coder Social home page Coder Social logo

drunkonbytes / flutter_collapsible_sidebar Goto Github PK

View Code? Open in Web Editor NEW
141.0 2.0 64.0 5.87 MB

A collapsible sidebar for Flutter apps implementing Material Design.

Home Page: https://pub.dev/packages/collapsible_sidebar

License: Apache License 2.0

Dart 95.96% Kotlin 0.30% Swift 0.96% Objective-C 0.09% HTML 2.70%
flutter widget flutter-package sidebar sidebar-menu sidebar-navigation collapsible-sidebar dart material hacktoberfest

flutter_collapsible_sidebar's Introduction

নমস্কার (Namaste)🙏🏻, I'm Arjun Sinha!

GIF

Associate Engineer at Commvault
Graduated from Visvesvaraya Technological University

Twitter Follow Linkedin: Arjun GitHub followers Medium Blogs Visitors

🌟 Welcome to my Dreamscape!

A little more about me...

const arjun = {
    pronouns: "He" | "Him",
    code: ["Flutter", "Python", "C++", "Java", "Golang"],
    askMeAbout: ["app dev", "tech", "personal finance", "anime"],
    technologies: {
        backEnd: {
            tech: ["Python", "Golang", "Firebase"]
        },
        mobileApp: {
            hybrid: ["Flutter Development"]
        },
        databases: ["MSSqlSever", "Firestore", "MongoDB"]
    },
    currentFocus: "Contributing to Open-Source projects in Golang",
    funFact: "The first computer “bug” was an actual real-life bug"
};

I love connecting with different people so if you want to say hi, I'll be happy to meet you more! 😊

Arjun's GitHub stats




snake

Octo Ring logo
previousrandomnext
check out other GitHub profiles in the Octo Ring

flutter_collapsible_sidebar's People

Contributors

asinha-cv avatar drunkonbytes avatar hashimsayed0 avatar jdayssol avatar kurtla avatar maliksenpai avatar pazican avatar shaunatpsynergy avatar taylanyildiz avatar thelonelynull avatar thelorddrake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_collapsible_sidebar's Issues

SubMenu

@RyuuKenshi

Can We Add Submenu in Sidebar?

Like this :
ORDERS >
OPEN ORDERS
CLOSED ORDERS

when add value to minWidth

how i can make the list of icons on the center of width
and selectedIconBox width dynamic with icon size or only around icon not full width

Screen Shot 2022-06-27 at 1 09 27 PM

h

Add isCollapse parameter

We should be able to set the collapse behaviour conditionally by setting isCollapse to true or false

The method 'toDouble' was called on null.

The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()

The relevant error-causing widget was:
CollapsibleSidebar file:///Users/imac/Documents/workspace/fittrack_flutter/lib/features/home/presentation/pages/home_screen.dart:48:21
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 double.* (dart:core-patch/double.dart:36:23)
#2 _CollapsibleSidebarState.build (package:collapsible_sidebar/collapsible_sidebar.dart:177:46)
#3 StatefulElement.build (package:flutter/src/widgets/framework.dart:4681:28)
#4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4564:15)
...

ERROR MOVE ON THIS LINE...

Stack(
alignment: Alignment.topCenter,
children: [
CollapsibleItemSelection(
height: _maxOffsetY,
======> offsetY: _maxOffsetY * _selectedItemIndex,
color: widget.selectedIconBox,
duration: widget.duration,
curve: widget.curve,
),
Column(children: _items),
],
),

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.

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?

Remove Collapse button?

Is there a way to remove the collapse button and simply make the collapsing behavior only occur with a media query?

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 !

`Index out of range` error

Hi, I am trying to create a simply three-item sidebar, but I am receiving the following error. I have three items in the sidebar, and it seems that the fourth item (index 3) is trying to be accessed. Any ideas on why this might be happening? Thanks for any help!

======== Exception caught by gesture ===============================================================
The following IndexError was thrown while handling a gesture:
RangeError (index): Index out of range: index should be less than 3: 3

When the exception was thrown, this was the stack: 
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 581:7                 _get]
packages/collapsible_sidebar/collapsible_sidebar.dart 392:44                      <fn>
packages/flutter/src/gestures/recognizer.dart 253:24                              invokeCallback
packages/flutter/src/gestures/tap.dart 627:11                                     handleTapUp
packages/flutter/src/gestures/tap.dart 306:5                                      [_checkUp]
packages/flutter/src/gestures/tap.dart 276:7                                      acceptGesture
packages/flutter/src/gestures/arena.dart 163:12                                   sweep
packages/flutter/src/gestures/binding.dart 464:20                                 handleEvent
packages/flutter/src/gestures/binding.dart 440:14                                 dispatchEvent
packages/flutter/src/rendering/binding.dart 336:11                                dispatchEvent
packages/flutter/src/gestures/binding.dart 395:7                                  [_handlePointerEventImmediately]
packages/flutter/src/gestures/binding.dart 357:5                                  handlePointerEvent
packages/flutter/src/gestures/binding.dart 314:7                                  [_flushPointerEventQueue]
packages/flutter/src/gestures/binding.dart 295:7                                  [_handlePointerDataPacket]
lib/_engine/engine/platform_dispatcher.dart 1183:13                               invoke1
lib/_engine/engine/platform_dispatcher.dart 243:5                                 invokeOnPointerDataPacket
lib/_engine/engine/pointer_binding.dart 156:39                                    [_onPointerData]
lib/_engine/engine/pointer_binding.dart 689:20                                    <fn>
lib/_engine/engine/pointer_binding.dart 620:14                                    <fn>
lib/_engine/engine/pointer_binding.dart 303:16                                    loggedHandler
lib/_engine/engine/pointer_binding.dart 188:80                                    <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39  dcall
Handler: "onTap"
Recognizer: TapGestureRecognizer#ee2a1
  debugOwner: GestureDetector
  state: ready
  won arena
  finalPosition: Offset(44.6, 94.0)
  finalLocalPosition: Offset(20.6, 10.0)
  button: 1
  sent tap down
====================================================================================================

Here is a minimum reproducible example

import 'package:flutter/material.dart';
import 'package:collapsible_sidebar/collapsible_sidebar.dart';

void main() => runApp(const WhisperApp());

class WhisperApp extends StatefulWidget {
  const WhisperApp({Key? key}) : super(key: key);

  @override
  State<WhisperApp> createState() => WhisperAppState();
}

class WhisperAppState extends State<WhisperApp> {
  @override
  void initState() {
    super.initState();
  }

  List<CollapsibleItem> get sidebarItems {
    return [
      CollapsibleItem(
        text: "Home",
        onPressed: () => print("home"),
        icon: Icons.home,
      ),
      CollapsibleItem(
        text: "Paths",
        onPressed: () => print("paths"),
        icon: Icons.folder,
      ),
      CollapsibleItem(
        text: "Settings",
        onPressed: () => print("settings"),
        icon: Icons.settings,
      ),
    ];
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark(),
      home: SafeArea(
        child: Scaffold(
          body: CollapsibleSidebar(
            items: sidebarItems,
            showTitle: false,
            body: const Center(child: Text("Home")),
          ),
        ),
      ),
    );
  }
}

Adapting the padding of the body when collapsing ( solved on my fork)

I found a small issue on the code, which I commented below.
It fixed the padding when using the collapse button.

padding: EdgeInsets.only(left: widget.maxWidth * 1.1), // Here is it maxWidth and not minWidth

See my merge request

return _isCollapsed ? Stack( alignment: Directionality.of(context) == TextDirection.ltr ? Alignment.topLeft : Alignment.topRight, children: [ Padding( padding: EdgeInsets.only(left: widget.minWidth * 1.1), child: widget.body, ), sidebar, ], ) : Stack( alignment: Directionality.of(context) == TextDirection.ltr ? Alignment.topLeft : Alignment.topRight, children: [ Padding( padding: EdgeInsets.only(left: widget.maxWidth * 1.1), // Here is it maxWidth and not minWidth child: widget.body, ), GestureDetector( onTap: () { if (widget.collapseOnBodyTap) { _isCollapsed = true; _animateTo(widget.minWidth); } }, child: Container( color: Colors.transparent, ), ), sidebar, ], );

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),
),

Enable tooltips on collapsed items

Allowing a simple mouse-over in flutter-web will enable us to see what an item means without performing a full expand/collapse. I have implemented this in my suggested PR at #57. The new example app (example_tooltip) also shows this in action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.