flutter_inner_drawer
flutter_inner_drawer copied to clipboard
add a getter for InnerDrawer status
current status of InnerDrawer is missing, i think its good for implementing double press back button to back or exit
@Viper-Bit this function is implemented
innerDrawerCallback: (a) => print(a), // return true (open) or false (close)
@Dn-a thx for review, yea with callback i must save the state again in another variable and in some cases pass it to parent classes (my drawer is in another class and another file than WillPopScope widget). this can help to detect the state after back button pressed in WillPopScope and make the drawer close
@override
Widget build(BuildContext context)
{
return InnerDrawer(
scaffold: Scaffold(
body: WillPopScope(
child: _myBody(),
onWillPop: _onWillPop,
.
.
.
),
),
key: _innerDrawerKey,
.
.
.
);
}
DateTime _currentBackPressTime;
Future<bool> _onWillPop() {
if (_innerDrawerKey.currentState.opened) {
_innerDrawerKey.currentState.close();
return Future.value(false);
}
DateTime now = DateTime.now();
if (_currentBackPressTime == null ||
now.difference(_currentBackPressTime) > Duration(seconds: 2)) {
_currentBackPressTime = now;
print('press again to exit');
return Future.value(false);
}
return Future.value(true);
}
I have a similar use case here is there a recommended way to do this if it's not the above?