Inner Drawer is an easy way to create an internal side section (left/right) where you can insert a list-menu or other.

Overview

flutter_inner_drawer

pub package Awesome Flutter Donate

Inner Drawer is an easy way to create an internal side section (left/right) where you can insert a list menu or other.

Installing

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_inner_drawer: "^1.0.0+1"

Demo

Simple usage

import 'package:flutter_inner_drawer/inner_drawer.dart';
.
.
.
   
    @override
    Widget build(BuildContext context)
    {
        return InnerDrawer(
            key: _innerDrawerKey,
            onTapClose: true, // default false
            swipe: true, // default true            
            colorTransitionChild: Color.red, // default Color.black54
            colorTransitionScaffold: Color.black54, // default Color.black54
            
            //When setting the vertical offset, be sure to use only top or bottom
            offset: IDOffset.only(bottom: 0.05, right: 0.0, left: 0.0),
            
            scale: IDOffset.horizontal( 0.8 ), // set the offset in both directions
            
            proportionalChildArea : true, // default true
            borderRadius: 50, // default 0
            leftAnimationType: InnerDrawerAnimation.static, // default static
            rightAnimationType: InnerDrawerAnimation.quadratic,
            backgroundDecoration: BoxDecoration(color: Colors.red ), // default  Theme.of(context).backgroundColor
            
            //when a pointer that is in contact with the screen and moves to the right or left            
            onDragUpdate: (double val, InnerDrawerDirection direction) {
                // return values between 1 and 0
                print(val);
                // check if the swipe is to the right or to the left
                print(direction==InnerDrawerDirection.start);
            },
            
            innerDrawerCallback: (a) => print(a), // return  true (open) or false (close)
            leftChild: Container(), // required if rightChild is not set
            rightChild: Container(), // required if leftChild is not set
            
            //  A Scaffold is generally used but you are free to use other widgets
            // Note: use "automaticallyImplyLeading: false" if you do not personalize "leading" of Bar
            scaffold: Scaffold(
                appBar: AppBar(
                    automaticallyImplyLeading: false
                ),
            ) 
            /* OR
            CupertinoPageScaffold(                
                navigationBar: CupertinoNavigationBar(
                    automaticallyImplyLeading: false
                ),
            ), 
            */
        )
    }
    
    //  Current State of InnerDrawerState
    final GlobalKey<InnerDrawerState> _innerDrawerKey = GlobalKey<InnerDrawerState>();    

    void _toggle()
    {
       _innerDrawerKey.currentState.toggle(
       // direction is optional 
       // if not set, the last direction will be used
       //InnerDrawerDirection.start OR InnerDrawerDirection.end                        
        direction: InnerDrawerDirection.end 
       );
    }
    

InnerDrawer Parameters

PropName Description default value
scaffold A Scaffold is generally used but you are free to use other widgets required
leftChild Inner Widget required if rightChild is not set
rightChild Inner Widget required if leftChild is not set
leftOffset(deprecated) Offset drawer width 0.4
rightOffset(deprecated) Offset drawer width 0.4
leftScale(deprecated) Left scaffold scaling 1
rightScale(deprecated) Right scaffold scaling 1
offset Offset InnerDrawer width IDOffset.horizontal(0.4)
scale Scaffold scaling IDOffset.horizontal(1)
proportionalChildArea If true, dynamically sets the width based on the selected offset, otherwise it leaves the width at 100% of the screen. true
borderRadius For scaffold border 0
onTapClose Tap on the Scaffold closes it false
swipe activate or deactivate the swipe true
swipeChild activate or deactivate the swipeChild false
duration Animation Controller duration Duration(milliseconds: 246)
velocity Allows you to set the opening and closing velocity when using the open/close methods 1
tapScaffoldEnabled Possibility to tap the scaffold even when open false
boxShadow BoxShadow of scaffold opened [BoxShadow(color: Colors.black.withOpacity(0.5),blurRadius: 5)]
colorTransitionChild Change background color while swiping Colors.black54
colorTransitionScaffold Change background color while swiping Colors.black54
leftAnimationType static / linear / quadratic static
rightAnimationType static / linear / quadratic static
backgroundDecoration possibility to manage the main background Decoration BoxDecoration(color: Theme.of(context).backgroundColor)
innerDrawerCallback Optional callback that is called when a InnerDrawer is opened or closed
onDragUpdate When a pointer that is in contact with the screen and moves to the right or left
_innerDrawerKey.currentState.open Current State of GlobalKey(check example) - OPEN
_innerDrawerKey.currentState.close Current State of GlobalKey(check example) - CLOSE
_innerDrawerKey.currentState.toggle Current State of GlobalKey(check example) - OPEN or CLOSE

Donate

It takes time to carry on this project. If you found it useful or learned something from the source code please consider the idea of donating 5, 20, 50 € or whatever you can to support the project.

  • Donate

Issues

If you encounter problems, open an issue. Pull request are also welcome.

Comments
  • the drawer become black on release mode

    the drawer become black on release mode

    the drawer works fine on debug mode on both the emulator and a real phone, but when running on release mode or after building the apk, it disappears completely.

    this is on debug mode: photo_2019-03-19_22-29-27

    this one on release mode: photo_2019-03-19_22-29-30

    both of them taken without any changes in the code.

    opened by waleedf112 11
  • Problem with StatefulWidgets in Version 0.5.6,

    Problem with StatefulWidgets in Version 0.5.6,

    Hello there! I noticed some unexpected behaviour after version 0.5.5 when using a StatefulWidget inside the InnerDrawer. Specifically the state of the widget is lost after swiping to the left or right (initState will be called).

    bug

    Here is a small code example to reproduce this behaviour.

    import 'package:flutter/material.dart';
    import 'package:flutter_inner_drawer/inner_drawer.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
            visualDensity: VisualDensity.adaptivePlatformDensity,
          ),
          home: Wrapper(),
        );
      }
    }
    
    class Wrapper extends StatefulWidget {
      @override
      _WrapperState createState() => _WrapperState();
    }
    
    class _WrapperState extends State<Wrapper> {
      final GlobalKey<InnerDrawerState> _innerDrawerKey =
          GlobalKey<InnerDrawerState>();
    
      @override
      Widget build(BuildContext context) {
        return InnerDrawer(
          offset: IDOffset.only(left: 0.7, right: 0.7),
          key: _innerDrawerKey,
    
          leftChild: Scaffold(
            body: Container(
              color: Colors.red,
            ),
          ),
          scaffold: StatefulPage(
            key: ValueKey("statefulPage"),
          ),
        );
      }
    }
    
    class StatefulPage extends StatefulWidget {
      StatefulPage({Key key}) : super(key: key);
    
      @override
      _StatefulPageState createState() => _StatefulPageState();
    }
    
    class _StatefulPageState extends State<StatefulPage> {
      int _counter = 0;
    
      void _incrementCounter() {
        setState(() {
          _counter++;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'You have pushed the button this many times:',
                ),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.headline4,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: _incrementCounter,
            tooltip: 'Increment',
            child: Icon(Icons.add),
          ), // This trailing comma makes auto-formatting nicer for build methods.
        );
      }
    }
    
    

    Any help would be appreciated Thank you :)

    bug 
    opened by JulianKeppelerCP 7
  • Can't hide keyboard when toggling the drawer

    Can't hide keyboard when toggling the drawer

    I can't get rid of the soft-keyboard when I toggle the drawer open and closed. I have tried putting a GestureDetector around the button but it is getting ignored.

    class SideBarButtonOpener extends StatelessWidget {
      SideBarButtonOpener({
        Key key,
      }) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return GestureDetector(
          onTap: () {
            print('toggling drawer...');
            FocusScope.of(context).unfocus();
          },
          child: NavBarButton(
            icon: Icons.menu,
            color: Colors.white,
            onPressed: () {
              Provider.of<LayoutProvider>(context, listen:false).currentDrawer.currentState.toggle();
            },
          ),
        );
      }
    }
    
    opened by brettpappas 6
  • Adding support to scale in the scaffold

    Adding support to scale in the scaffold

    This PR will adding the possibility of scale the scaffold allow user to create an effect of having the scaffold over the menu.

    image https://dribbble.com/shots/6351511-Menu-and-Dashboard/attachments

    opened by deividfortuna 6
  • When swipe set to true, then 'back' button on navigation bar not working

    When swipe set to true, then 'back' button on navigation bar not working

    I have a two page, Dashboard page and slidepanel page. Click a button in Dashboard page and then go to slidepanel page.

    I set 'swipe' parameter to be true. i click 'back' button on navigation bar. it cannot back to Dashboard.

    Also, i call Navigator.pop(context), which also not work.

    question 
    opened by KingWu 5
  • innerDrawerCallback fired multiple times

    innerDrawerCallback fired multiple times

    First of all, thanks for creating this amazing widget!

    I guess this is not really a bug, it's simply the way you implemented the innerDrawerCallback. When using a swipe gesture to open/close the drawer, I receive multiple callbacks (false, false, true when opening and true, true, false when closing).

    My issue is, that I only want one callback when the drawer is closed, so that I can safely perform one single update on the main screen.

    Any chance you could change this or give me a hint on how I could implement this? Thank You.

    opened by dimitristaufer 5
  • Two Page Example

    Two Page Example

    Hi @Dn-a due to Page(Scaffold) is an children of InnerDrawer how can we implement on two or more pages (Navigation Example)

        @override
        Widget build(BuildContext context)
        {
            return InnerDrawer(
                key: _innerDrawerKey,
                position: InnerDrawerPosition.start, // required
                onTapClose: true, 
                ...
                scaffold: Scaffold(
                    appBar: AppBar(
                        automaticallyImplyLeading: false
                    )
                )
            )
        }
    

    Default flutter drawer

    return Scaffold(
      appBar: AppBar(
        title: Text("Drawer app"),
      ),
      drawer: Drawer(),
    )
    
    opened by sfaizanh 3
  • I want to hide the back arrow in app bar

    I want to hide the back arrow in app bar

    This is the code

     Widget build(BuildContext context) {
        return InnerDrawer(
            colorTransitionChild: Colors.transparent,
            onTapClose: true,
            // tapScaffoldEnabled: true,
            boxShadow: [BoxShadow(color: Colors.grey)],
            //proportionalChildArea: false,
            //borderRadius: 12,
            innerDrawerCallback: (isOpened) {
              _isOpen = isOpened;
              print(_isOpen);
            },
            swipe: true,
            scale: IDOffset.horizontal(1),
            colorTransitionScaffold: Colors.transparent,
            offset: IDOffset.horizontal(0.15),
            key: key,
            rightChild: Container(
              color: Colors.white,
            ),
            scaffold: Scaffold(
              appBar: AppBar(
                leading: null,
                elevation: 1,
                title: Text('flutter.dart.lang'),
                actions: [
                  IconButton(
                      icon: Icon(Icons.menu),
                      onPressed: () {
                        key.currentState.toggle();
                      })
                ],
              ),
            ));
      }```
    opened by lalitjarwal 2
  • tapScaffoldEnabled: false, rebuilds whole page.

    tapScaffoldEnabled: false, rebuilds whole page.

    I am using InnerDrawer with PageView. But I have observed two things -

    1. tapScaffoldEnabled: false, every slightest gesture to open close drawer rebuilds the page
    2. tapScaffoldEnabled: true, no rebuild. Works as aspected
    return Material(
          child: InnerDrawer(
            key: _innerDrawerKey,
            tapScaffoldEnabled: false, //ISSUE HERE WHOLE PAGE GETS REBUILD
            onTapClose: true, // default false
            swipe: true, // default true
            colorTransitionChild: Colors.transparent,
            scale: IDOffset.horizontal(0.8), // set the offset in both directions
            proportionalChildArea: true, // default true
            borderRadius: 20, // default 0
            boxShadow: [BoxShadow(color: Colors.transparent, blurRadius: 0)],
            rightAnimationType: InnerDrawerAnimation.quadratic,
            backgroundDecoration: BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
                colors: [
                  Colors.green,
                  Colors.blue
                ],
              ),
            ), // default  Theme.of(context).backgroundColor
            rightChild: appRightMenu(), // required if leftChild is not set
            scaffold: Scaffold(
              body: PageView(
                physics: NeverScrollableScrollPhysics(),
                controller: _pageController,
                onPageChanged: onPageChanged,
                children: <Widget>[
                  PageOne(),
                  PageTwo(),
                  PageThree(),
                  PageFour(),
                ],
              ),
              bottomNavigationBar: BottomNavigationBar(
                      // showUnselectedLabels: false,
                      backgroundColor: ConfigSettings.baseColor,
                      unselectedItemColor: Colors.white54,
                      items: <BottomNavigationBarItem>[
                        BottomNavigationBarItem(
                          icon: Icon(CustomIcons.home, size: 20),
                          title: Text(translate("START"),
                              style: TextStyle(fontSize: 12)),
                        ),
                        BottomNavigationBarItem(
                          icon: Icon(CustomIcons.realtime, size: 20),
                          title: Text(translate("REALTIME_TRACKING"),
                              style: TextStyle(fontSize: 12)),
                        ),
                        BottomNavigationBarItem(
                          icon: Icon(CustomIcons.triplog, size: 22),
                          title: Text(translate("TRIPLOG"),
                              style: TextStyle(fontSize: 12)),
                        ),
                        BottomNavigationBarItem(
                          icon: const Icon(CustomIcons.units, size: 22),
                          title: Text(translate("CHOOSE_UNIT"),
                              style: TextStyle(fontSize: 12)),
                        ),
                        BottomNavigationBarItem(
                          icon: const Icon(CustomIcons.menu, size: 22),
                          title: Text(translate("MENU"),
                              style: TextStyle(fontSize: 12)),
                        ),
                      ],
                      type: BottomNavigationBarType.fixed,
                      currentIndex: _page,
                      iconSize: 24,
                      selectedItemColor: Colors.white38,
                      /*showSelectedLabels: false,  
                showUnselectedLabels: false,*/
                      onTap: navigationTapped,
                    ),
            ),
          ),
        )
    
    Observation 
    opened by watsmyname 2
  • Toogle drawer via _innerDrawerKey.currentState.toggle()

    Toogle drawer via _innerDrawerKey.currentState.toggle()

    I think its not a bug. But can you help me how deal with it?

    When I use _innerDrawerKey.currentState.toggle() - it open/close previously right or lelt panel. But I need toggle specific side - left (When user click menu button - it must open left panel)

    Thhanks!

    opened by uvlek 2
  • Change the scaffold when an item is selected

    Change the scaffold when an item is selected

    Hello ! First thanks for this awesome package ! I have an application which use inner_drawer like this:

    • A home scaffold
    • A right child, which is the main menu off my app. When the user open the right menu and choose an item, I would like to close the menu AND change the main scaffold using the statefull widget corresponding in the menu. The only problem I have, is how to change the main scaffold ?

    I have an idea to create a "Router Page" assigned to the main scaffold and change the returned Widget according, is it the good philosophy concerning this package ?

    Thanks for the answer :) Have a nice day !

    opened by istornz 2
  • Offer to help

    Offer to help

    At OneSheep we love this package and we are ready to invest in keeping it in good shape. @Dn-a would you consider inviting one of our developers as a collaborator on this repository? We are happy for them to spend company time to help review and tag issues, merge or close PRs, keep the documentation and examples up to date and anything else that can be of help to this project.

    opened by JannieT 1
  • Support devices with very narrow widths.

    Support devices with very narrow widths.

    Devices like the Samsung Galaxy Fold's outer screens have widths that are smaller than 300.

    This allows the drawer to be set to the correct width on these narrow screens rather than being locked to the initial 400 set here.

    opened by TheMeanCanEHdian 0
  • Fix animation behavior with negative horizontal offset to support narrower drawer.

    Fix animation behavior with negative horizontal offset to support narrower drawer.

    Currently, flutter_inner_drawer supports using a negative horizontal offset. However, doing so breaks the animation when revealing and hiding the drawer, forcing you to use a minimum horizontal offset of 0.

    This change fixes that, allowing drawers that are narrower than half the screen width to be configured. Supporting this is particularly useful for devices in landscape mode like tablets.

    The changes to the drift (difference in movement compared to gesture) is almost negligible and is comparable to the drift that already exists.

    The value of 2.05 was used when manually tuning as it offered the most similar experience for both positive and negative offsets.

    opened by TheMeanCanEHdian 0
  • Fix type cast using 'whereType' instead of 'as' operator

    Fix type cast using 'whereType' instead of 'as' operator

    Description

    This is the minimal fix for typecasting error caused in null safety mode.

    Implementation:

    Issue:

    <Widget?>[....].where((a) => a != null).toList() as List<Widget>
    
    // causes type 'List<Widget?>' is not a subtype of type 'List<Widget>' in type cast
    

    Fix:

    <Widget?>[....].where((a) => a != null).whereType<Widget>().toList()
    

    Effective line numbers: [435-437], [600-620]

    Related Issues

    #69 #70 #71 #72

    opened by bikcrum 2
  • Crash in null-safety mode

    Crash in null-safety mode

    type 'List<Widget?>' is not a subtype of type 'List' in type cast

    The relevant error-causing widget was: InnerDrawer-[LabeledGlobalKey#e0d93] When the exception was thrown, this was the stack: #0 InnerDrawerState.build (package:flutter_inner_drawer/inner_drawer.dart:634:52) #1 StatefulElement.build (package:flutter/src/widgets/framework.dart:4612:27) #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4495:15) #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11) #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)

    Observation 
    opened by ykrank 10
Releases(v0.4.0)
A Beautiful Side Drawer Made With Flutter

Flutter Custom Drawer A beautiful side drawer. Made with Flutter ?? A while back, using Facebook, I stumbled upon a post on the Flutter Developers gro

Aashar Wahla 12 Dec 23, 2022
A beautiful drawer for flutter

flurry_drawer The repo is solving a problem with package flurry_navigation as it's old any the owner didn't update it. The drawer is very beautiful an

null 4 Feb 15, 2022
FLUTTER API: It's powerful navigation by gestures and taps. You can scroll from left to right or tap on the navigation icons.

scroll_navigation My other APIs Video Viewer Video Editor Helpers Features Fancy animations. Customizable colors. Works with the back button. Scrollin

Luis Felipe Murguia Ramos 14 Jun 14, 2022
Hidden Drawer Menu is a library for adding a beautiful drawer mode menu feature with perspective animation.

Hidden Drawer Menu Hidden Drawer Menu is a library for adding a beautiful drawer mode menu feature with perspective animation. You can use a pre-defin

Rafael Almeida Barbosa 298 Jan 2, 2023
Custom bottom bar - A bottom tool bar that can be swiped left or right to expose more tools.

custom_bottom_bar A bottom tool bar that can be swiped left or right to expose more tools. usage Create your custom bottom bars with up to four custom

null 4 Jan 26, 2020
A Flutter Widget that create a horizontal table with fixed column on left hand side.

horizontal_data_table A Flutter Widget that create a horizontal table with fixed column on left hand side. Installation This package is starting to su

May Lau 204 Dec 27, 2022
A iOS like table view including section, row, section header and divider

flutter_section_table_view A iOS like table view including section, row, section header and divider Support both Android and iOS Support drop-down ref

刘彦博 73 Nov 4, 2022
Flutter tableview - A flutter widget like iOS UITableview. let listView with section header and each section header will hover at the top.

中文 flutter_tableview A flutter widget like iOS UITableview. let listView with section header and each section header will hover at the top. Installing

null 41 Jul 22, 2022
Flutter drawer (dynamic ready side menu)

Flutter side menu (Drawer) Getting Started Use KFDrawer widget as Scaffold's body with items property (List<KFDrawerItem>) you should define onPressed

null 213 Dec 5, 2022
A Flutter package with custom implementation of the Side Menu (Drawer)

Flutter Awesome Drawer Bar A Flutter package with custom implementation of the Side Menu (Drawer) Getting Started To start using this package, add awe

Appcheap 4 Nov 13, 2022
Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Custom Radio Group List Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map. Feature

Ashok Kumar Verma 0 Nov 30, 2021
Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navigation Drawer in Flutter.

Flutter Tutorial - Collapsible Sidebar Menu & Navigation Drawer Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navig

Johannes Milke 22 Jan 3, 2023
Flutter Scrollable Widgets like ListView,GridView or powerful CustomScrollView can't nest inner scrollview

Introduction Flutter Scrollable Widgets like ListView,GridView or powerful CustomScrollView can't nest inner scrollview. If Nested, inner scrollview w

jaysonss 5 Aug 28, 2022
An easy to use side menu in flutter and can used for navigations

Easy Sidemenu Easy sidemenu is An easy to use side menu (bar) for flutter that you can use for navigations in your application. Sidemenu is a menu tha

Mohammad Jamalianpour 86 Dec 29, 2022
Let's create a selectable Flutter Navigation Drawer with routing that highlights the current item within the Flutter Sidebar Menu.

Flutter Tutorial - Sidebar Menu & Selectable Navigation Drawer Let's create a selectable Flutter Navigation Drawer with routing that highlights the cu

Johannes Milke 12 Dec 26, 2022
Flutter Insert, Update, Delete and add form view dynamic

salesapp Insert, Update, Delete and form view add dynamic. Getting Started This project is a starting point for a Flutter application. A few resources

null 1 Dec 22, 2021
A ListView that allows you to group list items and support headers like iOS UITableView section.

GroupListView package for Flutter. A ListView that allows you to group list items and support headers like iOS UITableView section. Features List Item

Daniel Ioannou 73 Nov 21, 2022
This is a mason brick you can use to generate code that get's you started right up with a flutter project

flutter_brick This is a mason brick you can use to generate code that gets you started right up with a flutter project A flutter brick created with th

Bruce Omukoko 3 Sep 16, 2022
This is a repository for Flutter Focused Menu, an easy to implement package for adding Focused Long Press Menu to Flutter Applications

Focused Menu This is an easy to implement package for adding Focused Long Press Menu to Flutter Applications Current Features Add Focused Menu to Any

Paras Jain 160 Dec 26, 2022
Liquid swipe with Drawer - Liquid swipe application with full customizable drawer with govt logo

Liquid swipe with Drawer Liquid swipe application with full customizable drawer

Munem Sarker 1 Jan 19, 2022