flutter 如何使用webview检测你是否在底部页面?

ppcbkaq5  于 2023-06-07  发布在  Flutter
关注(0)|答案(1)|浏览(269)

无法检测webview中的滚动
enter image description here目前这是我的代码。我尝试使用scrollcontroller并将gesturerecognizer设置为VerticalDragGestureRecognizer if(_scrollController.position.pixels == _scrollController.position.maxScrollExtent){ setState((){ _reachedBottom = true;}); } else { setState((){ _reachedBottom = false;); }

pobjuy32

pobjuy321#

在initState中更新your _controller如下:

void initState() {
    super.initState();

    // Setup the listener.
    controller.addListener(() {
      if (_controller.position.atEdge) {
        bool atBegin = _controller.position.pixels == 0;
        if (atBegin) {
          /// here you are at the top
          print('here you are at the top');
        } else {
          /// here you are at the bottom
          print('here you are at the bottom');
        }
      }
    });
  }

相关问题