I'm new to Flutter, and currently, I'm making a very simple app, which is just a WebView. My question is how can I insert this code into my Flutter WebView?
footer#footer, div#st_notification_1, #sidebar_box {
display: none!important;
}
As of the moment, I'm trying to use WebView plugin by the Flutter Team on one of my application tabs. The website I'm trying to load and hiding the footer after is:
below is my code for that tab Webview that I'm trying to hide the footer
UPDATED: FIXED IT. The code below is working for me
Note: I also re-inspect the website and changed the getElementsById
to getElementsByClassName
corresponding to the class name of the footer on the website above.
Note2: There are plenty of WebView apps in Flutter packages, I'm using the Flutter Webview by the Flutter team.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class ProfileAccount extends StatefulWidget {
ProfileAccount({Key key}) : super(key: key);
@override
_ProfileAccountState createState() => _ProfileAccountState();
}
class _ProfileAccountState extends State<ProfileAccount> {
WebViewController _myController;
final Completer<WebViewController> _controller =
Completer<WebViewController>();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: WebView(
initialUrl: 'https://syncshop.online/en/login',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
_myController = controller;
},
onPageFinished: (initialUrl) {
_myController.evaluateJavascript("document.getElementsByClassName('footer-container')[0].style.display='none';");
},
)
),
);
}
}