Ways to conceal flutter webview within a mobile application

Is there a way to run code and libraries written in JavaScript within my Flutter mobile app without displaying the webview component in the UI? I am currently using webview_flutter for this purpose, but I want the webview to be hidden. How can I achieve this in Flutter?

Answer №1

I successfully resolved my issue by using webview_flutter_plus: ^0.1.1+9 and incorporating the Visibility widget with the required settings. The code snippet demonstrating this solution is provided below:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Webview counter: ' + scounter),
      ),
      body: Column(
        children: <Widget>[
          Visibility(
            visible: false,
            maintainState: true,
            child: SizedBox(
              height: 1,
              child: WebViewPlus(
                onWebViewCreated: (controller) {
                  this._webViewController = controller;
                  controller.loadUrl("files/test.html");
                },
                onPageFinished: (url) {
                  _webViewController.getHeight().then((double height) {
                    print("height: " + height.toString());
                    setState(() {
                      _height = height;
                    });
                  });
                },
                javascriptMode: JavascriptMode.unrestricted,
                javascriptChannels: <JavascriptChannel>[_counterx()].toSet(),
              ),
            ),
          ),
          Text("Webview above"),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.add),
        onPressed: () {
          _webViewController.evaluateJavascript('reset()');
        },
      ),
    );
  }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Establishing a Connection Between Data Store and App Engine via Android Studio

The Objective: My current project involves developing a basic app using Android Studio and Google App Engine. This app serves as a simple proof of concept without any advanced features. Essentially, it tracks the number of times a button is clicked within ...

Find the matching ID and consolidate all the information under one single ID

I am looking to merge objects with the same title and consolidate their data into a single object. new = [{ "data": [{ "displayName": "Peter pvt ltd", "name": "Peter Zon"}], "title&quo ...

Ways to set values for attributes

I am seeking guidance on how to set values for the properties foo and greetingMessage App.vue: <template> <img alt="Vue logo" src="./assets/logo.png"> <HelloWorld msg="Welcome to Your Vue.js App"/> < ...

Creative jQuery hover effects tailored to the size of the viewport

Currently expanding my knowledge of jQuery and encountering an issue with some code. I am trying to incorporate an animation effect (fadeIn/fadeOut) when the user hovers over a specific element. However, if the viewport is resized to below 480px for mobil ...

"Please note that the function of the enter key to navigate between form fields is

When I use the enter key to move between form fields, it's not working as expected: The cursor doesn't move to another field in the form when I press the enter key. Removing the submit button allows the enter key to work properly. The issue se ...

"Enhance your database by incorporating HTML link clicks through AJAX integration with PHP and MySQL

After browsing through similar questions and attempting to implement it on my website, I'm facing an issue where the expected functionality is not working as intended. When users click on a link, there is no response in the console, and the database r ...

There seems to be a React Native Navigation issue displaying the error message: "'Main' is required to have a screen

I am currently troubleshooting an issue with React Native and the new React Navigation. I have encountered an error on a specific screen in my project. The navigation flow is as follows: MainScreen -> Login redirects to Splash Screen Splash -> clic ...

What is the process for adding my JSON data to a select dropdown list?

Looking to populate a selectlist in HTML with options retrieved from an API. Below is the HTML code : <div id="example" role="application"> <div class="demo-section k-header"> <select id="FeaturesSelec ...

Issue with jQuery animation: Background color does not change upon scrolling

Here is my fiddle link: https://jsfiddle.net/jzhang172/owkqmtcc/5/ I am attempting to change the background color of the "content" div when scrolling anywhere within it. The goal is for the background color to change when scrolling and revert back to its ...

Tips for accessing VC from Custom CollectionViewCell nested within a TableViewCell

Currently, I have a setup where there is a tableView and within each cell of the table view, there is a collectionView displaying certain content. My goal is to send a link when a specific indexPath is selected. I am looking to navigate to another view f ...

How is it possible that the two CGRect objects do not intersect in code even though they clearly overlap visually?

I am currently working on an app where users can input information using various UITextFields. There is an issue with the keyboard sometimes hiding the text fields, so I need to adjust the view when the keyboard's CGRect intersects with the frame of t ...

Invalid Blob URL functionality on Android web browsers

I have developed a straightforward web application using .NET (including Entity Framework) and AngularJS for fetching PDF files. Everything works smoothly on desktop browsers and iOS browsers, but I am encountering difficulties in getting it to function pr ...

The content within the tab is currently being loaded

Incorporating jQuery UI tabs into my webpage, I encounter a delay of 5-6 seconds when clicking on a tab as it triggers an ajax call for preparing and displaying content. The screen stays idle during this time, leading to user confusion. I am seeking a sol ...

Having trouble with Jquery's Scroll to Div feature?

When I click on the image (class = 'scrollTo'), I want the page to scroll down to the next div (second-container). I've tried searching for a solution but nothing seems to work. Whenever I click, the page just refreshes. Any help would be gr ...

Guide for setting up a React infinite scroll feature in a messaging app similar to Facebook Messenger

I have been exploring various questions regarding React infinite scroll, but I am looking to delve deeper in order to discover the most effective solution available for implementing such a component. Currently, I am working on a chat application and have ...

Ways to prevent a specific class from using CSS styling

My HTML <body> <div id="finalparent"> <!--many parent divs here--> <div id="1stparent"> <div id="txt_blog_editor" class="box" style="width: 1097px;"> <div class="abc anotherclass"> </div> & ...

Building an HTML form to generate an array of objects by collecting form data

Hey there, I'm working on an HTML form in React that utilizes form action and FormData. However, when I extract the formData using my method, it shows a structure like this: https://i.stack.imgur.com/nzgLX.png My goal is to have an array of objects ...

What is the best approach for dynamically accessing or rendering Children within an Angular Component?

I am facing an issue with reusing a component called wrapper with different child components. I found some helpful resources such as this SO question and this article. However, these only address cases where the child component is known in advance. In my s ...

Display a partial form in Rails using Ajax

There is a form displayed in the image below: Next, I aim to render this partial from an ajax call, specifically from .js.erb. However, I am unsure how to pass an object to f from the partial. Take a look at the image below for reference: Is there a way ...

personalized XMLHttpRequest method open

var open = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, uri, async, user, pass) { this.addEventListener("readystatechange", function(event) { if(this.readyState == 4){ var self = this; var respons ...