2

我正在使用https://pub.dev/packages/persistent_bottom_nav_bar包来显示底栏。当按下底部栏标签之一时,我需要打开底部工作表。我已经设法使用 showModalBottomSheet 显示底页,但问题是它覆盖了现有的底栏。我需要在底栏上方而不是从屏幕底部打开底页。这就是我想要实现的。

在此处输入图像描述

所以我设法使用带有 Container 和底部边距的 showGeneralDialog 来展示。下面是我的解决方案。

showGeneralDialog(
        barrierLabel: AppLocalizations.of(context).translate(LanguageConstant.more),
        barrierDismissible: true,
        barrierColor: Colors.grey.withOpacity(0.1),
        transitionDuration: Duration(milliseconds: 100),
        context: context,
        pageBuilder: (dialogContext, anim1, anim2) {
          return Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              margin: EdgeInsets.only(bottom: CommonConstants.BOTTOM_BAR_HEIGHT, top: MediaQuery.of(context).size.height/2, left: 0, right: 0),
              decoration: BoxDecoration(
                  color: Theme.of(context).colorScheme.surface,
                  border: Border.all(width: 0.5,color: ColorConstants.blackShade3),
              ),
              child: <Your child widgets>,
            ),
          );
        },
        transitionBuilder: (dialogContext, anim1, anim2, child) {
          return SlideTransition(
            position: Tween(begin: Offset(0, 1), end: Offset(0, 0)).animate(anim1),
            child: child,
          );
        },
      );
4

0 回答 0