How can I use a javascript lib in flutter web? - javascript

So im developing a project in flutter web and my client request the use of a package which is not available for flutter web (dart). This package is available in js (https://github.com/torusresearch/CustomAuth).
I wanted to know if there is any way that I can make use (or install) this package inside my flutter web project and make use of it. I know Im able to call javascript code inside flutter, but this may get a little bit complex when it requires the use of js packages. I know that there is this package in flutter -> https://pub.dev/packages/js , that can help with the implementation of javascript code.
Anyone knows how can I achieve this goal?

Related

Transplanting Javascript application to iOS/Android flutter

I have browser application which uses javascript,node.js,jquery,HTML5(canvas).
Now I want to transplant this application to iOS/Android.
I am familiar with making iOS/Android application by flutter, so I know that it is possible to make iOS/Android/webapp from dart code.
However for vice-versa??? is there any way to make iOS/Android from HTML5??
Flutter is best but ,any other way???
For example on Titanaium, is it possible to make application by Javascript.
But, it means language is javascript but no library like jquery doesn't work.
So my idea is ,,, use webview on flutter and use application via this view,, but is it possible???
Take a look at Apache Cordova. Although I'm not a fan of it and I'd advise you to write the application natively (with Java or Kotlin), Cordova is quite known and some apps on the store use it.
https://cordova.apache.org/

Can I call a function from flutter PWA using Javascript? if yes how?

I'm currently trying to connect a JS code to my flutter web app. And then call a function from my flutter application in JS.
I'm thinking the problem is, flutter PWA is compiled to js (main.dart.js) and thus it's function names, and function bodies are lost. Am I right about this? Is there a way to solve this?
Thanks!
the Dart team has you covered with an interop js package which lets you call JS from the Dart VM -> package link. If you're already using that and you're encounting an error with that - lemme know.

How to use a JS library and a JS function in a Flutter mobile app?

I want to use a JavaScript library in my mobile Flutter project. Here is the link for this library on github.
Library
How can I use this library and a function(aboutnumber()) from it in my project? How can I import this library to a project and how to access its function?
You can use https://pub.dev/packages/flutter_js package.
It allows to evaluate pure javascript code inside mobile and desktop flutter apps. By pure, I mean the package is not a browser engine, so no web API , localstorage or another browser api are available. But you can bundle some javascript code containing javascripts libraries like moment, ajv and maybe the one you related in your question if it relies only in javascript. The flutter_js injects into the javascript engine, things like console.log, xhr and fetch. But it is all. There is a send message channel which you could use to inject objects into the engine which you could provide objects which will be implemented and dart, but will be shared into the javascript global space.
In Flutter web, the javascript integration is possible using the package:js, mentioned in another answer.
Disclaimer: I'm the author of the flutter_js package
This is not possible on any platform other than the web, as described in the JS interop documentation.
On the Web, package:js can be used.
As mentioned in this other similar question, there's also webview_flutter, which embeds a whole web view onto Flutter, and that's an official Flutter package as well.

Run java code inside javascript

I want to build a site that calls a pi and displays the results. The problem is the API is a jar file that i normally import into a java project and go from there. However i want to build a web app but not sure i how can interact with my jar file.
I see some folks executing the jar in a command line but im not sure that the same, i want to interact with all the methods exposed to me via this java API by the jar file.
any ideas if there is a popular way of doing this or a framework i could use?
You can use spring MVC, you can build web apps there, consume the API jar file and do whatever you want in the views(frontend) with javascript and so on.
I recommend you use thymeleaf, which is pretty simple and easy.
If you want to build a fast app I also recommend you to use spring boot
You will build an app within minutes
https://spring.io/guides/gs/spring-boot/

Javascript package manager inside the browser

I'd really like a package manager like Bower etc that I can just call from javascript in a browser to load a javascript package from the web and use it right away. Right now I'm just trying to use Jsdelivr, which unfortunately has no real api and lacks necessary integration conventions.
Is there any existing way to do this?

Categories