sliding_drawer 1.0.2 copy "sliding_drawer: ^1.0.2" to clipboard
sliding_drawer: ^1.0.2 copied to clipboard

A Flutter widget that provides a drawer with the sliding effect.

Sliding Drawer #

pub style: very good analysis license: MIT


A Flutter widget that provides a drawer with the sliding effect.

🎯 Features #

  • Easy to use API
  • Any direction support
  • Customizable drawer width
  • Controller which manages a drawer state
  • Customizable shade color

⚙️ Getting started #

Add the following line to pubspec.yaml:

dependencies:
  sliding_drawer: ^1.0.2

🚀 Usage #

  1. Create a SlidingDrawerController in the state of your stateful widget:
class _SomeWidgetState extends State<SomeWidget> {
  // Create a drawer controller.
  // Also you can set up the drawer width and
  // the initial state here (optional).
  final SlidingDrawerController _drawerController = SlidingDrawerController(
    this.isOpenOnInitial = false,
    this.drawerFraction = 0.7,
  );

  @override
  void dispose() {
    // Clean up the controller when the widget is removed
    // from the widget tree.
    _drawerController.dispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // Fill this out in the next step.
  }
}
  1. Create a SlidingDrawer and connect the controller to it:
SlidingDrawer(
  // Connect the controller to the drawer.
  controller: _drawerController,
  // You can set up some optional properties
  // (eg, a shade color, an axis direction, a onShadedAreaTap callback)
  shadeColor: Colors.black,
  axisDirection: AxisDirection.right,
  onShadedAreaTap: () {},
  // Add a drawer widget.
  drawer: const Scaffold(
    body: ColoredBox(
      color: Colors.amber,
      child: Center(
        child: Text('Drawer'),
      ),
    ),
  ),
  // Add a body widget.
  body: const Scaffold(
    body: ColoredBox(
      color: Colors.pink,
      child: Center(
        child: Text('Body'),
      ),
    ),
  ),
);
  1. (Optional) Use the controller to interact with the drawer (e.g., for closing):
// Call the animateClose method to close the drawer with an animation. 
_drawerController.animateClose(
    duration: const Duration(milliseconds: 300),
    curve: Curves.easeOut,
);

❤️ Additional information #

Pull requests are welcome!

If you encounter any problems or you have any ideas, feel free to open an issue:

There might be some grammar issues in the docs. I would be very grateful if you could help me to fix it.

1
likes
160
points
64
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter widget that provides a drawer with the sliding effect.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on sliding_drawer