I want to print (on printer, not console) from a dart chrome app.
It is possible to print from chrome apps. Here is official sample.
This works properly for javascript apps, however I cannot do similar in dart.
Here's what I tried:
import 'dart:html';
import 'package:chrome/chrome_app.dart' as chrome;
void main() {
chrome.app.window.current().print();
}
Thanks in advance.
Update:
There seems to be no print() method in AppWindow object.
The question is how can I in dart access print() method? I mean the one that is available in javascript in window object. Not in regular dart runtime environment but when code is executed as chrome app written in dart.
Update2:
I posted the answer. The remaining mystery is how to get the DOM Window object from AppWindow object?
The answer seems to easier than I thought...
window.print()
does the job as described in documentation.
Related
I try to use JavaScript library visjs.org in Dart. I prepared ‘adapter’ code according examples on Dart site pub.dartlang.org/packages/js and github.com/google/chartjs.dart/blob/master/lib/chartjs.dart.
Also according basic use case example from http://visjs.org I prepare client dart code.
While code compiles without any errors and warnings nothing happens in browser, expected to see graph-tree.
What I did wrong or miss to do?
https://gist.github.com/EdSv/e274a4d12ad3491c383fb4fe76ee671e
The attribute #anonymous is meant to be used when the object you're describing doesn't actually exist in the JS library you're binding, and is only used as a plain old data object. By adding it to all of your objects, my guess is that dart is never attempting to create anything from the visjs library.
Try removing the #anonymous from your Network class and see if that has an effect. You will likely also need to make these abstract classes as well.
Dartium raises a "Not Supported" exception when calling Element.animate(), and Chrome, via dart2js, doesn't do anything at all.
Web Animations via JavaScript work completely fine in the aforementioned browsers.
Does Dart actually support Web Animations?
There seems to be a bug in the Element.animate API. It looks like the problem is that it takes Map arguments, and it's not being correctly converted, so in dart2js we're passing a Dart LinkedHashMap to JS, and it doesn't understand it. So it's just a matter of convincing the generation script to add the right type conversions. At least for dart2js, I haven't yet investigated Dartium.
I get Exception: Unsupported operation: [info: ../../third_party/WebKit/Source/bindings/core/dart/custom/DartElementCustom.cpp:100] even with an example that worked months ago.
Please create a bug report.
Below chunk of code seems to require dart:io.
HttpRequest.getString(uri).then(onDataLoaded);
The App that is being designed requires to make HttpRequests to fetch metadata and build up a HTML page. But when the below is executed, an error related to dart:io of not being availble in Dartium is output on console.
Error as below
The built-in library 'dart:io' is not available on Dartium.
Any suggestions would be helpful.
You haven't provided much code to see what you are actually doing.
In the browser you need to import import 'dart:html'; and use the HttpRequest class from there.
is it possible to parse in a user entered string, say from a text area, and then incorporate it into a dart function which you can then run, without having to post it back to the server? I guess I'm looking for a dart eval equivalent.
There is no notion of eval in Dart, and it is not possible to dynamically build code. You can run code in a different isolate using spawnUri (see http://api.dartlang.org/docs/releases/latest/dart_isolate.html). When not running in the Dartium browser, note that the Dart code needs to be compiled to JavaScript using dart2js. The site http://try.dartlang.org/ does all that.
Some time in the future Dart might get mirror builders which can be used for "programs to extend and modify themselves" (citation from last paragraph in https://www.dartlang.org/articles/reflection-with-mirrors/).
I now know that I can't interact with Dart via the console, but I was hoping that there may be another way to invoke a REPL within Dartium.
Basically, what I would like to be able to do is:
1. Go to a website in Dartium
2. Invoke some sort of Dart REPL
3. Mess about with the DOM, CSS etc., using Dart commands, rather than Javascript.
Is this possible at all? Or, is the Dart development model all Edit/Refresh?
Cheers
Andy
Chrome Dev tools in Dartium will now let you do this very nicely.
Dart edit model is Edit/Refresh.
Maybe you are looking for something like http://try.dartlang.org/