How to pass Authentication Header in Flutter WebSocketChannel? - flutter

I'm using Flutter web_socket_channel package to communicate with server. The class WebSocketChannel doesn't take a header parameter.
factory WebSocketChannel.connect(Uri uri, {Iterable<String>? protocols}) =>
platform.connect(uri, protocols: protocols);
When using IOWebSocketChannel to pass header, I'm getting Unsupported operation: Platform._version in web like given here. It is working fine in Android and iOS.

The concise answer is: No because only the path in your URI and protocol field can be set up.
Longer answer:
In the pure JS WebSocket API, there is no method to specify extra headers for the browser to send.
You can specify only
GET query(was://mysockets.com/path)
and header protocol called Sec-WebSocket-Protocol
Conclusion: If you can't achieve such functionality in the native code then this functionality is unavailable for your flutter web app
Happy coding

Related

How to access window.navigator.serial in flutter web

On some browsers there exists the the property serial on the window.navigator object.
I can see it on chrome but not on safari.
How can I access that object via dart in flutter web?
dart:html doesn't seem to include it. Is there a way to manually extend the window.navigator object to include it?
In the end I didn't access the window.navigator object from dart.
I access the serial and do all of the checks in javascript.
I use Js context to get data back from the Javascript.

How to use deep link in flutter web using navigator 2.0 on my webserver?

I can refresh(reload) and deep link when I launch debug in IDE(vscode)
However when I published to own webserver(I made web resource from this command 'flutter web build'), My webserver is intercept my url and return 404.. :(
It can enter from main page only
Webserver is runing on golang and Flutter web using navigator 2.0
How can I solve this?
I can't find reference of flutter navigator 2.0 in web.
Please save my life
The problem because removed hash(#) in url
I was follow this
How to remove hashtag (#) from url in web flutter
but this is cause that problem
When I back to original url(include hash), problem solved.
Please have a look at this code sample that uses new MaterialApp.router() constructor to handle url path.
In the parseRouteInformation of the RouteInformationParser you get the raw url and it's up to you how are you going to interpret the data. For instance, in the above sample the route is converted to object TheAppPath and later handled by RoutePageManager and RouterDelegate.

The error creating app Engine's DataStore Entity within GWT app

I try to create the entity like this:
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity stock = new Entity("Stock", 1);
stock.setProperty("Stock", "FCB");
ds.put(stock);
but keep getting the error:
No source code is available for type com.google.appengine.api.datastore.DatastoreService; did you forget to inherit a required module?
The error means just what it says, the GWT compiler needs access to the Java source it compiles to Javascript, and obviously DatastoreService is not something that should exist on the frontend - so you have an architecture issue here.
You'll need to write a proxy that can call a server component (Which in turns calls the DatastoreService) and returns DTOs/value objects (that you define and thus have the source for).
Cheers,
No source code is available
GWT transliterate Java to Javascript, reading it's source code and there a limited language support.
What you're trying to achieve is a Server only operation and you're adding this operation within the client code, which will run on a browser. Neither GAE allow this or GWT has the source of these classes nor capability to do so.
Solution
You need to create a request to your server that will access the DatastoreService , the return the output to the client code.
Below a example of a properly architect GWT web application:

Dynamic Form Builder In Android

Can any body know how to implement the dynamic form builder base on API response in Android ?
I don't know how to build it in android activity and what's required api response.
I refer the bellow link for implement it in android
Dynamic Form Builder with CodeIgniter
database schema for a dynamic formbuilder
but can't understand exactly what was required
So, please help me if there any one know dynamic form builder.
After a long terms, I got a some good library JASONETTE-Android and Avocarrot/json2view which basically work on JSON object to implement the dynamically form of Android means you can convert your JSON object to Android View.

Making GWT application crawlable by a search engine

I want to use the #! token to make my GWT application crawlable, as described here:
http://code.google.com/web/ajaxcrawling/
There is a GWT sample app available online that uses this, for example:
http://gwt.google.com/samples/Showcase/Showcase.html#!CwRadioButton
Will serve the following static webpage to the googlebot:
http://gwt.google.com/samples/Showcase/Showcase.html?_escaped_fragment_=CwRadioButton
I want my GWT app to do something similar. In short, I'd like to serve a different flavor of the page whenever the _escaped_fragment_ parameter is found in the URL.
What should I modify in order for the server to serve something else (a static page, or a page dynamically generated through a headless browser like HTML Unit)? I'm guessing it could be the web.xml file, but I'm not sure.
(Note: I thought of checking the Showcase app provided with the GWT SDK, but unfortunately it doesn't seem to support serving static files on _escaped_fragment_ and it doesn't use the #! token..)
If you want to use web.xml, then I think it won't work with a servlet-mapping, because the url-patterns ignore the get parameters. (Not 100% sure, if there is another way to make this possible.)
You could of course map Showcase.html to a servlet, and in that servlet decide what to do, based on the get parameter "_escaped_fragment_". But it's a little bit expensive to call a Servlet just to serve a static page for the majority of the requests (not too bad, but still. You could set cache headers, if you're sure that it doesn't change).
Or you could have an Apache or something in front of your server - but I understand, I wouldn't like to have to do that either. Maybe your JavaEE server (which one are you using BTW?) provides some mechanism for URL filtering before the request gets passed on to the web container - I'd like to know that, too!
Found my answer! The Showcase sample supporting crawlable hyperlinks is in the following branch:
http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/?r=7726
It defines a filter in the web.xml to redirect URLs with the _escaped_fragment_ token to the output of HTML Unit.