Flutter -在软键盘后面插入覆盖层

nzkunb0c  于 2023-03-19  发布在  Flutter
关注(0)|答案(1)|浏览(159)

为了保持键盘在导航上,我们可以使用覆盖,而不是我创建了我的小部件构建在OverlayEntry上,并插入到屏幕上的覆盖中

问题当我插入我的overlayEntry来覆盖键盘后面的小部件!

结果实际上它应该像电报一样在键盘上进行

我创建的覆盖代码就是谢谢你的帮助

// Remove the OverlayEntry.
  void removeHighlightOverlay() {
    if(overlayEntry != null){
      overlayEntry?.remove();
      overlayEntry = null;
    }
  }

  void createHighlightOverlay() {
    // Remove the existing OverlayEntry.
       removeHighlightOverlay();
    assert(overlayEntry == null);

    overlayEntry = OverlayEntry(
      // Create a new OverlayEntry.
      builder: (BuildContext context) {

        // Align is used to position the highlight overlay
        // relative to the NavigationBar destination.
        return GestureDetector(
          onTap: (){
            removeHighlightOverlay();
          },
          child: Builder(
            builder: (BuildContext context) {
              return Container(
                color: Colors.black54,
                child: FocusedMenuDetails(
                                  menuContent: widget.menuContent,
                                  child: widget.child,
                                  childOffset: childOffset,
                                  childSize: childSize!,
                                  parentSize: parentSize!,
                                  parentOffset: parentOffset,
                                )
              );
            },
          ),
        );
      },
    );

    // Add the OverlayEntry to the Overlay.
    Overlay.of(context, debugRequiredFor: widget).insert(overlayEntry!);
  }
kx5bkwkv

kx5bkwkv1#

哎呀!
https://github.com/flutter/flutter/issues/121452
根本没有办法做出这样的东西!
我必须创造一个未来来解决Flutter问题

相关问题