weDrawer function
Implementation
ShowDrawer weDrawer(BuildContext context) {
final GlobalKey widgetKey = GlobalKey();
CloseDrawer showDrawer({
mask = true,
maskClosable = true,
placement = WeDrawerPlacement.left,
background,
onClose,
child,
}) {
late Function remove;
// 关闭方法
close() async {
// 反向执行动画
await (widgetKey.currentState as DrawerWidgetState).reverseAnimation();
// 执行回调
if (onClose is Function) onClose();
// 销毁
remove();
}
remove = createOverlayEntry(
context: context,
child: DrawerWidget(
key: widgetKey,
mask: mask,
placement: placement,
maskClick: maskClosable ? close : null,
background: background,
child: child,
),
willPopCallback: () {
if (maskClosable) {
close();
}
},
);
return close;
}
return showDrawer;
}