Dn-a / flutter_inner_drawer

Inner Drawer is an easy way to create an internal side section (left/right) where you can insert a list-menu or other.
https://pub.dartlang.org/packages/flutter_inner_drawer
MIT License
514 stars 129 forks source link

I use both LeftSide and RightSide, but I show Right, then Left will be unmount! who to hold leftside? #50

Closed Siwen closed 3 years ago

Siwen commented 4 years ago

I use both LeftSide and RightSide, but I show Right, then Left will be unmount! who to hold leftside?

Siwen commented 3 years ago

I have Fixed It !!!! :>

 // --->
// 以下工作,只为保证LeftChild保持状态存活
// 导致原因是:Stack在显示RightChild时,LeftChild从Stack的childs中移除导致
// 也就是说 Stack 只保存当前显示内容和上一个页面
Widget leftChildKeepAlive = Container();
if( _position != InnerDrawerDirection.start) {
  leftChildKeepAlive = Offstage(
    offstage: true,
    child: widget.leftChild,
  );
}
// <----

return Container(
  decoration: widget.backgroundDecoration ??
      BoxDecoration(
        color: Theme.of(context).backgroundColor,
      ),
  child: Stack(
    alignment: _drawerInnerAlignment,
    children: <Widget>[
      // --- >
      leftChildKeepAlive,
      // < ----
      FocusScope(node: _focusScopeNode, child: _animatedChild()),