curved_drawer 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

curved_drawer #

A Flutter widget that provides an easy to use animated drawer.

Gif

Add dependency #

dependencies:
  curved_drawer: ^0.1.2 #latest version

Simple Implementation #

Scaffold(
  drawer: CurvedDrawer(
    color: Colors.white,
    labelColor: Colors.black54,
    width: 75.0
    items: <DrawerItem>[
      DrawerItem(icon: personIcon),
      //Optional Label Text
      DrawerItem(icon: messageIcon, label: "Messages")
    ],
    onTap: (index) {
      //Handle button tap
    },
  ),
  body: Container(),
)

Attributes #

items: List of DrawerItems index: Index of selected item - can be used to change current index or to set initial index
color: Color of drawer - default Colors.white buttonBackgroundColor: Background color of floating button - default same as color attribute
backgroundColor: Color of NavigationBar's background - default Colors.transparent onTap: Function handling taps on items
animationCurve: Curves interpolating button change animation - default Curves.easeOutCubic
animationDuration: Duration of button change animation - default Duration(milliseconds: 600)
width: Width of Drawer - default min 50.0, max 100.0 isEndDrawer: Set to true if used as as an end drawer - default is false

[0.1.2] #

  • Moved DrawerItem implementation to the curved_drawer.dart. Renamed drawer_item.dart to drawer_nav_item.dart

[0.1.1] #

  • Changed 3rd Cubic component from 0.45 to 0.50 multiplier

[0.1.0] #

  • Formatting Changes in the dart files

[0.0.1] #

  • Initial Version, 1.28.2020

example/example.dart

import 'package:curved_drawer/curved_drawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main(){
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp
    ]);
    return MaterialApp(
      title: 'Animation Playground',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Playground(title: 'Curved Drawer Demo'),
    );
  }
}

class Playground extends StatefulWidget {
  Playground({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _PlaygroundState createState() => _PlaygroundState();
}

class _PlaygroundState extends State<Playground> {
  int index = 0;
  double leftWidth = 75.0;
  int leftTextColor = 1;
  int leftBackgroundColor = 0;
  double rightWidth = 75.0;
  int rightTextColor = 1;
  int rightBackgroundColor = 0;
  final List<Color> colorPallete = <Color>[
    Colors.white, Colors.black, Colors.blue, Colors.blueAccent, Colors.red, Colors.redAccent, Colors.teal, Colors.orange, Colors.pink, Colors.purple, Colors.lime, Colors.green
  ];
  List<DrawerItem> _drawerItems = <DrawerItem>[
    DrawerItem(icon: Icon(Icons.people), label: "People"),
    DrawerItem(icon: Icon(Icons.trending_up), label: "Trending"),
    DrawerItem(icon: Icon(Icons.tv)),
    DrawerItem(icon: Icon(Icons.work), label: "Work"),
    DrawerItem(icon: Icon(Icons.web)),
    DrawerItem(icon: Icon(Icons.videogame_asset)),
    DrawerItem(icon: Icon(Icons.book), label: "Book"),
    DrawerItem(icon: Icon(Icons.call), label: "Telephone")
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      drawer: CurvedDrawer(
        index: index,
        width: leftWidth,
        color: colorPallete[leftBackgroundColor],
        buttonBackgroundColor: colorPallete[leftBackgroundColor],
        labelColor: colorPallete[leftTextColor],
        items: _drawerItems,
        onTap: (newIndex){
          setState(() {
            index = newIndex;
          });
        },
      ),
      endDrawer: CurvedDrawer(
        index: index,
        width: rightWidth,
        color: colorPallete[rightBackgroundColor],
        buttonBackgroundColor: colorPallete[rightBackgroundColor],
        labelColor: colorPallete[rightTextColor],
        isEndDrawer: true,
        items: _drawerItems,
        onTap: (newIndex){
          setState(() {
            index = newIndex;
          });
        },
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Current index is $index',
            ),
            SizedBox(height: 15,),
            Text("Left Width = $leftWidth"),
            Slider(
              label: "Left Drawer Width",
              activeColor: Colors.blue,
              min: 50.0,
              max: 100.0,
              divisions: 50,
              value: leftWidth,
              onChanged: (value) => setState(()=> leftWidth = value),
            ),
            SizedBox(height: 15,),
            SliderTheme(
              child: Slider(
                label: "Left Drawer Background Color",
                activeColor: colorPallete[leftBackgroundColor],
                min: 0,
                max: colorPallete.length.toDouble()-1.0,
                divisions: colorPallete.length,
                value: leftBackgroundColor.toDouble(),
                onChanged: (value) => setState((){ leftBackgroundColor = value.toInt();}),
              ),
              data: SliderThemeData(
                valueIndicatorTextStyle:  TextStyle(color: Colors.grey)
              )
            ),
            SizedBox(height: 15,),
            SliderTheme(
              child: Slider(
                label: "Left Drawer Label Color",
                activeColor: colorPallete[leftTextColor],
                min: 0,
                max: colorPallete.length.toDouble()-1.0,
                divisions: colorPallete.length,
                value: leftTextColor.toDouble(),
                onChanged: (value) => setState((){ leftTextColor = value.toInt();}),
              ),
              data: SliderThemeData(
                valueIndicatorTextStyle: TextStyle(color: Colors.grey)
              )
            ),
            SizedBox(height: 15,),
            Text("Right Width = $rightWidth"),
            Slider(
              label: "Right Drawer Width",
              activeColor: Colors.blue,
              min: 50.0,
              max: 100.0,
              divisions: 50,
              value: rightWidth,
              onChanged: (value) => setState(()=> rightWidth = value),
            ),
            SizedBox(height: 15,),
            SliderTheme(
              child: Slider(
                label: "Right Drawer Background Color",
                activeColor: colorPallete[rightBackgroundColor],
                min: 0,
                max: colorPallete.length.toDouble()-1.0,
                divisions: colorPallete.length,
                value: rightBackgroundColor.toDouble(),
                onChanged: (value) => setState((){ rightBackgroundColor = value.toInt();}),
              ),
              data: SliderThemeData(
                valueIndicatorTextStyle: TextStyle(color: Colors.grey)
              )
            ),
            SizedBox(height: 15,),
            SliderTheme(
              child: Slider(
                label: "Right Drawer Label Color",
                activeColor: colorPallete[rightTextColor],
                min: 0,
                max: colorPallete.length.toDouble()-1.0,
                divisions: colorPallete.length,
                value: rightTextColor.toDouble(),
                onChanged: (value) => setState((){ rightTextColor = value.toInt();}),
              ),
              data: SliderThemeData(
                valueIndicatorTextStyle: TextStyle(color: Colors.grey)
              )
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  curved_drawer: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:curved_drawer/curved_drawer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test