Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/helper/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import 'dart:ui';

import 'package:flutter_slider_drawer/flutter_slider_drawer.dart';

/// Signature for the callback that's called when a [DrawerController] is
/// opened or closed.
typedef DrawerCallback = void Function(bool isOpened);

class Utils {
///
/// This method get Offset base on [sliderOpen] type
Expand Down
42 changes: 26 additions & 16 deletions lib/src/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,24 @@ class SliderDrawer extends StatefulWidget {
///
final bool isCupertino;

const SliderDrawer(
{Key? key,
required this.slider,
required this.child,
this.isDraggable = true,
this.animationDuration = 400,
this.sliderOpenSize = 265,
this.splashColor = const Color(0xffffff),
this.sliderCloseSize = 0,
this.slideDirection = SlideDirection.LEFT_TO_RIGHT,
this.sliderBoxShadow,
this.appBar = const SliderAppBar(),
this.isCupertino = false})
: super(key: key);
/// Optional callback that is called when the [Scaffold.drawer] is opened or closed.
final DrawerCallback? onDrawerChanged;

const SliderDrawer({
Key? key,
required this.slider,
required this.child,
this.isDraggable = true,
this.animationDuration = 400,
this.sliderOpenSize = 265,
this.splashColor = const Color(0xffffff),
this.sliderCloseSize = 0,
this.slideDirection = SlideDirection.LEFT_TO_RIGHT,
this.sliderBoxShadow,
this.appBar = const SliderAppBar(),
this.isCupertino = false,
this.onDrawerChanged,
}) : super(key: key);

@override
SliderDrawerState createState() => SliderDrawerState();
Expand Down Expand Up @@ -146,8 +150,14 @@ class SliderDrawerState extends State<SliderDrawer>
super.initState();

_animationDrawerController = AnimationController(
vsync: this,
duration: Duration(milliseconds: widget.animationDuration));
vsync: this, duration: Duration(milliseconds: widget.animationDuration))
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
widget.onDrawerChanged?.call(true);
} else if (status == AnimationStatus.dismissed) {
widget.onDrawerChanged?.call(false);
}
});

_animation =
Tween<double>(begin: widget.sliderCloseSize, end: widget.sliderOpenSize)
Expand Down