Flutter - dart.ui no method 'platformViewRegistry' - html

Im working on Flutter web and I want to render an html code. Since flutter_webview_plugin doesnt support flutter web yet Im using IFrameElement and HtmlElementView. But I have this problem when using dart.ui, platformViewRegistry method isn't defined.
Error message:
The name 'platformViewRegistry' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix.
import 'dart:ui' as ui;
......
ui.platformViewRegistry.registerViewFactory(
createdViewId,
(int viewId) => html.IFrameElement()
..width = MediaQuery.of(context).size.width.toString() //'800'
..height = MediaQuery.of(context).size.height.toString() //'400'
..srcdoc = """<!DOCTYPE html><html>
<head><title>Page Title</title></head><body><h1>This is a Heading</h1><p>This is a paragraph.</p></body></html>"""
..style.border = 'none');
Example Code From: https://stackoverflow.com/a/60089273/12789200
I read some solution to solve this problem. But I don't want to downgrade my flutter version. Since in the past month Flutter has a lot of changes
Flutter Doctor
[√] Flutter (Channel beta, 1.22.1, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.49.3)
[√] Connected device (3 available)
Is there any other solution for this problem? Or another example I can used for WebView on Flutter Web.

Up to my knowledge I have tried several solutions and apparently there is a problem in the 'dart:ui' package .
The solutions I've tried are:
Tried using a WebView widget //Failed No web support yet
Tried rendering on HTML instead of CanvasKit //UI will look rubbish
Tried editing on the **analysis_options.yaml**
Tried adding a comment above the code that said //ignore: undefined_prefixed_name
All these solutions referred to other errors, the solution was to use a package called:
universal_ui from the https://pub.dev/packages/universal_ui , which is apparently the same as 'dart:ui' package, but with all methods included.
Hope this works for you !

Related

Add notification to Windows notification center without displaying it on screen

I am building an Electron app featuring a custom Notification feature where html5 divs appear and disappear as needed on a frameless, transparent, always-on-top window.
It works great, but: I still like the Windows notification center itself, and would like to have the option to see the past notifications there, without actually displaying them on screen with the HTML5 api.
I have tried:
Looking into the HTML5 api for an option to not show a notification, or to .hide() it right away: no luck. The only method that comes close is .close(), and it removes the notification from the center as well.
Looking into packages like node-notifier, but none of the used notification dependencies offer a way to completely hide a notification.
While I mentioned Node, I will also accept any lower-level API/binding that would allow me to do this.
Thanks in advance.
With the help of #treckstar in comments, I have found a way to do what I wanted using:
NodeRT
The ToastNotification.SuppressPopup attribute
Despite a handful of troubles building NodeRT and using electron-rebuild, here's a working PoC:
const { XmlDocument } = require('#nodert-win10-rs4/windows.data.xml.dom');
const {
ToastNotification,
ToastNotificationManager
} = require('#nodert-win10-rs4/windows.ui.notifications');
const localImage = path.join(__dirname, 'icon.png');
const template = `
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<image id="1" placement="appLogoOverride" hint-crop="circle" src="${localImage}"/>
</binding>
</visual>
</toast>
`;
const xml = new XmlDocument();
xml.loadXml(template);
const toast = new ToastNotification(xml);
const notifier = ToastNotificationManager.createToastNotifier("com.myapp.testnotif");
toast.suppressPopup = true;
notifier.show(toast);
May this help whoever comes across the same highly-specific problem.
In addition to what #MadWard shows in the PoC, the suppressPopup key is really the main player of the solution.
As I was going through tons of examples and electron code I kept hitting roadblocks due to random SDK versions and libraries of things I had installed. For example, the package electron-windows-notifications, which uses NodeRT was failing to load my preload.js because the Windows 10 SDK I had installed (build 15063) needed nodert-win10-cu instead of what was being used in most solutions by default nodert-wind10-au.
SDK
Known As
Windows Version
npm Scope
Windows 10, Build 17134
April 2018 Update (Redstone 4)
1803
npmjs.com/org/nodert-win10-rs4
Windows 10, Build 16299
Fall Creators Update (Redstone 3)
1709
npmjs.com/org/nodert-win10-rs3
Windows 10, Build 15063
Creators Update (Redstone 2)
1703
npmjs.com/org/nodert-win10-cu
Windows 10, Build 14393
Anniversary Update (Redstone 1)
1607
npmjs.com/org/nodert-win10-au
Windows 10, Build 10586
Threshold 2
1511
npmjs.com/~nodert-win10
EDIT: I forgot to include the more specific steps I took getting electron-windows-notifications dependency files on this GitHub issue here. Basically everything from Python, broken node-gyp, and missing .winmd files.
Lastly Electron 14+ and NodeRT have an issue where you will need to make sure to have app.allowRendererProcessReuse = false and like the readme file says, to make sure this is running in the main.js file.
Hopefully this helps someone along the way, as I had never used Electron before until today and had learned a ton thanks to other peoples help.

Viewing console output from TVJS

I'm working with the tvOS beta 3 and trying to do some basic debugging on the tvml/tvjs side of things.
Messages logged via console.log(...) in my js files don't appear in the main Xcode output window.
Is there somewhere else I can find these messages or a setting which needs to be configured?
You should actually use the debug console in Safari. (The developer forum suggests you use Safari 9 and upgrade to El Capitan, both of which I have so haven't been able to test with inferior version)
Open Safari > Develop menu > Simulator
Your app name should appear here once and from there you can use the console.
Give it a few seconds to appear, it's not always instantaneous.
You must give a name to the Bundle Identifier in General/Identity (com.yourcompany.appname) to appear the app in the developers tool.
If you are developing a hybrid application (TVML/TVJS + Swift) with TVMLKitchen you can implement a logging function in Swift and use it in the TVJS code. For my projects I use the following code:
Kitchen.appController.evaluateInJavaScriptContext({context in
let printInJS : #convention(block) (NSString!) -> Void = {
(string : NSString!) -> Void in
print("Log: \(string)\n")
}
context.setObject(unsafeBitCast(printInJS, AnyObject.self), forKeyedSubscript: "printInJS")
})

Quintus to Android

I have tried to Google and read the Quintus wiki but no solution. Why does quintus platformer need server to run? Because this I can't use phonegap nor cocoonjs to convert my project to android game. Is there a better HTML5 2d game engine that I can use without server? Or what can I do to get quintus run as android application?
So I finally managed to get the game running with little bit of help, so I am answering here for myself. To get the game running on Android phone you need to quote some code.
Try commenting out this code from your quintus.js file and try again. I was facing a similar issue, commenting out this code resolved it:
if(document.location.origin === "file://" || document.location.origin === "null") {
if(!Q.fileURLAlert) {
Q.fileURLAlert = true;
alert("Quintus Error: Loading assets is not supported from file:// urls - please run from a local web-server and try again");
}
return errorCallback();
Then compile it with CocoonJS Webview+ and install debug.apk to get the game running.

Map issues when testing in IOS 8

I have an application that uses MapBox's API to stylize the underlying map which uses Google Places. This all worked perfectly fine when running in IOS 7+, but when I try testing this in IOS 8, it immediately crashes with the following error message:
Terminating app due to uncaught exception NSInternalInconsistencyException, reason: 'The layout constraints still need update after sending -updateConstraints to MapView at {0,0}-{320x444}.
RMMapView or one of its superclasses may have overridden -updateConstraints without calling super. Or, something may have dirtied layout constraints in the middle of updating them. Both are programming errors.'
I have been looking around the Web and Stack for a while but have been unable to find anything helpful unfortunately. Any suggestions?
I deleted all Mapbox framework / headers / lib from my project and reinstalled the latest (1.4.1) mapbox static library (libMapbox.a) and the Headers, and everything was ok after that without changing a line of my code.

Is Worklight App based on Dojo toolkit 1.9 supported in Windows phone 8?

I am working on a worklight App using it's default 1.9 Dojo Toolkit. My App is working fine in Android emulator and in the web browser simulator. I tried to test the same app in Windows phone 8 Emulator but I am not able to see the whole Home page. I can see only Tabbar Button part used at the button while I am not able to see the list items used in the page. My Question is does Dojo Toolkit 1.9 supports Windows Phone 8?
I have visited dojo 1.9 release link and It says that in dojo 1.9, support for Windows Phone 8 has been included. If this is true, What could be the reason of failure for my app in Windows phone 8 emulator?
I also got below log when I created Windows phone 8 environment in my Worklight Project.
[2013-11-12 22:14:08] Environment 'Windows Phone 8' was created.
[2013-11-12 22:14:13] Starting build process: application 'KaiserTestApp', environment 'windowsphone8'
[2013-11-12 22:14:28] Windows Phone 8 app may not work well with Dojo toolkit included for this Application. Use a different Worklight Project, without Dojo toolkit, for Windows Phone 8 apps.
[2013-11-12 22:14:28] Application 'KaiserTestApp' with environment 'windowsphone8' build finished.
There is a WP8 VM bug that might hurt ListItem and might explain your issue. To check if that you are falling into this just monkey patch the _ItemBase _setSelectedAttr method this way and see if that fixes your issue:
_setSelectedAttr: function(/*Boolean*/selected){
// summary:
// Makes this widget in the selected or unselected state.
// description:
// Subclass should override.
// tags:
// private
if(selected){
var p = this.getParent();
if(p && p.selectOne){
// deselect the currently selected item
var arr = array.filter(p.getChildren(), function(w){
return w.selected;
});
array.forEach(arr, function(c){
this._prevSel = c;
c.set("selected", false);
}, this);
}
}
this.selected = selected;
//this._set("selected", selected);
}
If that is fixing your issue let us know and we will see how to release an updated version of Dojo that workarounds that WP8 WM bug.