1 | initial version |
You can use the onScroll
parameter of the InAppWebView
widget to identify a scroll event. The onScroll
parameter takes a function that will be called when the web view is scrolled. The function returns a double
value that represents the current scroll position of the web view. You can use this value to determine when the user has scrolled to the bottom of the page, for example.
Here's an example:
class MyWebView extends StatefulWidget {
@override
_MyWebViewState createState() => _MyWebViewState();
}
class _MyWebViewState extends State<MyWebView> {
InAppWebViewController _webViewController;
double _scrollPosition = 0;
@override
Widget build(BuildContext context) {
return InAppWebView(
initialUrl: "https://flutter.dev",
onWebViewCreated: (controller) {
_webViewController = controller;
},
onScrollChanged: (controller, x, y) {
setState(() {
_scrollPosition = y;
});
},
// other parameters...
);
}
}
In this example, the onScrollChanged
function is called every time the web view is scrolled, and the _scrollPosition
variable is updated to reflect the new scroll position. You can then use this variable to perform any actions you need to, such as detecting when the user has scrolled to the bottom of the page.