Using flutter_inAppWebView, how do I programmatically close the web view? - flutter

I'm using flutter_inappwebview and I've got it working, but I want to programmatically close the web view and trigger onCloseWindow to emit an event.
I'm tried importing things like dart:html as html to try to use html.window.close but my linter doesn't seem to like that. I get Error: Not found: 'dart:html and Error: undefined name windowon top of a warning:Avoid using web-only libraries outside Flutter web plugin packages.`.
How do I close this window to trigger onCloseWindow?

Related

codesandbox how to update code in editor and trigger save through JavaScript?

I am using a very similar platform to codesandbox for adding/editing code where I simply need to open code tab and update some content, like in the example below - update "PING" to something like "PONG". This has to be done through JS code (for now I am just trying from chrome console), to be more precise - I will be using my chrome plugin to find and update text.
While my plugin finds and updates element in the code tab just fine, the save is not triggered, if I am doing this manually using my keyboard, then autosave is working just fine. I understand code container fires some events when I type in some text and then saves it, but I have no luck finding what has to be triggered in order to call autosave, tried various el.dispatchEvent(...keyup/keydown/keypress ..etc ..) methods, no luck yet.
Any assistance is greatly appreciated.
https://codesandbox.io/s/summer-dawn-psdsh?file=/index.html

How to simulate click on button Flutter WebView

I am using the package webview_flutter. How can I simulate a button click? I tried using the controller to run some javascript:
controller.evaluateJavascript("$('.mybuttonclass').click()")
Unfortunately It seems we cannot use JQuery here as I received a '$ not found error'. Is there a possible workaround?
Try
document.getElementById("myButtonId").click()
Or getElementsByClassName

Can't click on web element with flutter appium driver that is covered by other element

I tried to test a webview in flutter app using flutter appium driver and faced a problem:
In a webview I have a text, that is placed in two lines. Because of that placing text is covered by another element.
I tried 3 approaches:
1.appium driver: mouse.moveTo then mouse.click.
Solution with mouse.moveTo then mouse.click did not work because appium need other parametr called duration, that is not included to parameters in our appium_driver.
2. Used flutter inspector to locate elements on the webview - solution was not succeed because this webviews are external and were not covered by any flutter overlay.
3. Clicking by bounds
Got all objects from the webview with TESTWorld().appiumDriver.pageSource. Found out that we have the xml with all objects on webview with properties as bounds,text. Made a list with 3 objects of “MyString“ string and clicked on them one by one with click() method from appium_driver. Second element “MyString“ is clickable, appium can click on it, but first instance of this string is in two lines, so this element is part of other big element, that’s why appium_driver can’t click on it.
Maybe someone knows another approach?
Because of that placing text is covered by another element
In a particular case, it sounds like an AUT issue. Appium uses WebDriver API for testing WebView and it is expected to not be able to interact with the overlapped element.
If there is no way to address and fix it in the app, you can try JS to send a click action (the same way we do in Webdriver):
WebElement textElement = driver.findElement(...);
JavascriptExecutor jsEx = (JavascriptExecutor)driver;
jsEx.executeScript("arguments[0].click();", textElement);

flutter, after push a native viewController from flutter, is this possible display more content above native viewController with flutter again?

I have a native viewController which implement from a framework, I can't directly change it into flutter view.
So I think I can:
Display the UI in native ViewController(a 3rd party native video player) from flutter main app.
Then I need display some extra content(for example user avatar, some text message and so on) above/on native ViewController
But I would prefer implement this extra content with flutter, if it's possible?
Is this good approach ? If not, then I think have to do the things bellow:
Display the UI in native ViewController(a video player) from flutter main app.
Then display some extra content with native code.
PS: why I can't change the native VideController into flutter ? it's because it integration with a native video player which integration cache logic and I can't change the source code in that.
According to [1] it is fine to have some component native, because there just are not all features in new cross platform frameworks like flutter.
According to [2] you could use Decorators from Container to show content in layers, taken that you can show the native content embedded to the Flutter code. In that case, definitely use approach 1.
However, I could only find platform-channels type of solution from Flutter documentation [4] to do native code execution and there it states for example this:
To comply with channels’ UI thread requirement, you may need to jump from a background thread to Android’s UI thread to execute a channel method.
and in other post [3] on platform-channels:
When the user clicks back I want to navigate back to flutter [..]
Both imply everything that is native happens in native thread and view, so I don't see possibility other than your second approach, where all is native.
So, all depends how you fit the native element to Flutter. If you embed, use Flutter for overlays, otherwise do all native. I think good way to measure this is that if you see anything from Flutter generated code when inside the native viewer, you have chances to overlay, otherwise just go native.
[1] Open native UIViewController in Flutter
[2] https://cogitas.net/overlay-text-icon-image-flutter/
[3] How to change the root view controller back to flutter from native iOS?
[4] https://flutter.dev/docs/development/platform-integration/platform-channels

using unityscript to write a popup for unity 3d based app for ios

I am trying to write apopup plugin for my unity 3d ios based app, I want to write a plugin that will create a button that will open a new window, and in the new window put a link to a website. I know how to generate a button, but then I get stuck, help any body ?!, thanks.
In case you understand plug-in as a set of GUI elements, you can use the new ModalWindow (v4.1.2) or make your very own custom via the GUI class.
http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html
http://docs.unity3d.com/Documentation/ScriptReference/GUI.html
In case you don't like UnityGUI, you can get some other third-party libraries to get your job done, as NGUI: http://www.tasharen.com/?page_id=140
Take a look at Unity's Asset Store for more packages.