Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(awesome_drawer_bar): Adding didUpdateWidget to also sync the controller param to the widget. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 18 additions & 8 deletions lib/awesome_drawer_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,7 @@ class _AwesomeDrawerBarState extends State<AwesomeDrawerBar> with SingleTickerPr
curve: Curves.slowMiddle,
));
// CurvedAnimation(parent: _animationController, curve: Curves.easeIn); //Curves.easeIn Curves.linear
/// assign controller function to the widget methods
if (widget.controller != null) {
widget.controller!.open = open;
widget.controller!.close = close;
widget.controller!.toggle = toggle;
widget.controller!.isOpen = isOpen;
widget.controller!.stateNotifier = stateNotifier;
}
syncController();
}

_updateStatusNotifier() {
Expand All @@ -195,6 +188,12 @@ class _AwesomeDrawerBarState extends State<AwesomeDrawerBar> with SingleTickerPr
super.dispose();
}

@override
void didUpdateWidget(AwesomeDrawerBar oldWidget) {
super.didUpdateWidget(oldWidget);
syncController();
}

/// Build the widget based on the animation value
///
/// * [container] is the widget to be displayed
Expand Down Expand Up @@ -263,6 +262,17 @@ class _AwesomeDrawerBarState extends State<AwesomeDrawerBar> with SingleTickerPr
);
}

/// Sync the controller with the drawer
syncController() {
if (widget.controller != null) {
widget.controller!.open = open;
widget.controller!.close = close;
widget.controller!.toggle = toggle;
widget.controller!.isOpen = isOpen;
widget.controller!.stateNotifier = stateNotifier;
}
}

openDrag(DragUpdateDetails details) {
double dx = details.delta.dx;
if ((dx > 6 || dx < 6 && _state == DrawerState.open) && !widget.isRTL) {
Expand Down