Inner Drawer – An easy way to create an internal side section

  packages, Packages, Sidebar, Widgets

flutter inner drawer

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: "^0.5.7+2"

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

PropNameDescriptiondefault value
scaffoldA Scaffold is generally used but you are free to use other widgetsrequired
leftChildInner Widgetrequired if rightChild is not set
rightChildInner Widgetrequired if leftChild is not set
leftOffset(deprecated)Offset drawer width0.4
rightOffset(deprecated)Offset drawer width0.4
leftScale(deprecated)Left scaffold scaling1
rightScale(deprecated)Right scaffold scaling1
offsetOffset InnerDrawer widthIDOffset.horizontal(0.4)
scaleScaffold scalingIDOffset.horizontal(1)
proportionalChildAreaIf true, dynamically sets the width based on the selected offset, otherwise it leaves the width at 100% of the screen.true
borderRadiusFor scaffold border0
onTapCloseTap on the Scaffold closes itfalse
swipeactivate or deactivate the swipetrue
swipeChildactivate or deactivate the swipeChildfalse
durationAnimation Controller durationDuration(milliseconds: 246)
velocityAllows you to set the opening and closing velocity when using the open/close methods1
tapScaffoldEnabledPossibility to tap the scaffold even when openfalse
boxShadowBoxShadow of scaffold opened[BoxShadow(color: Colors.black.withOpacity(0.5),blurRadius: 5)]
colorTransitionChildChange background color while swipingColors.black54
colorTransitionScaffoldChange background color while swipingColors.black54
leftAnimationTypestatic / linear / quadraticstatic
rightAnimationTypestatic / linear / quadraticstatic
backgroundDecorationpossibility to manage the main background DecorationBoxDecoration(color: Theme.of(context).backgroundColor)
innerDrawerCallbackOptional callback that is called when a InnerDrawer is opened or closed
onDragUpdateWhen a pointer that is in contact with the screen and moves to the right or left
_innerDrawerKey.currentState.openCurrent State of GlobalKey(check example) – OPEN
_innerDrawerKey.currentState.closeCurrent State of GlobalKey(check example) – CLOSE
_innerDrawerKey.currentState.toggleCurrent State of GlobalKey(check example) – OPEN or CLOSE

Download flutter inner drawer widget source code on GitHub

https://github.com/Dn-a/flutter_inner_drawer

Check out the details of Flutter inner drawer package details on pub.dev

https://pub.dev/packages/flutter_inner_drawer