'Scroll-to-top WebView in flutter
Is there a way to make a floating button auto-scrolling to the top of a WebView and not a ListView with flutter? This is the simple one-page flutter code where WebView is being used.
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:webview_flutter/webview_flutter.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with TickerProviderStateMixin{
WebViewController? webViewController;
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Welcome to Flutter',
home: SafeArea(
child : WillPopScope(
onWillPop: () => _exitApp(context),
child : Scaffold(
body: Stack(
children: <Widget> [
WebView(
initialUrl: "https://google.com",
zoomEnabled: false,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller){
webViewController = controller;
},
return true;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
