首页 > 解决方案 > flutter 是如何让 PopupRoute 不覆盖 appbar 的?

问题描述

使用PopopRoute弹出的图片中的白块。我需要通过点击appbar来关闭这个popop。但是我发现appbar似乎被覆盖了,我点击它并没有事件响应。

在此处输入图像描述

void showTop() {
     // Get the coordinates of the click control
    final RenderBox button = _buttonKey.currentContext.findRenderObject();
    final RenderBox overlay = Overlay.of(context).context.findRenderObject();
    // Get the coordinates of the bottom left of the control
    var a = button.localToGlobal(Offset(0.0, button.size.height),
        ancestor: overlay);

    // Get the coordinates of the bottom right of the control
    var b = button.localToGlobal(button.size.bottomLeft(Offset(0, 0)),
        ancestor: overlay);
    final RelativeRect position = RelativeRect.fromRect(
      Rect.fromPoints(a, b),
      Offset.zero & overlay.size,
    );
    final RenderBox body = _bodyKey.currentContext.findRenderObject();

    showPopupWindow(
      context: context,
      fullWidth: true,
      position: position,
      elevation: 3.0,
      child: GestureDetector(
        onTap: () {
          NavigatorUtils.goBack(context);
          setState(() {
            isShow = false;
          });
        },
        child: Container(
          // color: const Color(0x99000000),
          height: body.size.height,
          child: Container(
            alignment: Alignment.center,
            height: double.infinity,
            color: Colors.white10,
            child: Text("Im Test?"),
          ),
        ),
      ),
    );
}

因为showPopupWindow代码太长,我单独做了个链接展示一下

网址 ===> https://cdn.clk528.com/showPopupWindow.dart

标签: flutter

解决方案


推荐阅读