dart-html

passing parameter/input data to custom elements in DART

落花浮王杯 提交于 2019-12-02 07:53:54
问题 I created a custom element, and want to send data / parameters to it: my element code is: class SaveBtn extends HtmlElement { static final tag = 'save-button'; factory SaveBtn()=>new Element.tag(tag); SaveBtn.created() : super.created() { // Create a Shadow Root var shadow = this.createShadowRoot(); // Create a standard element and set it's attributes. var btn = new ButtonElement(); ... btn.text= this.getAttribute('data-name'); shadow.nodes.add(btn); Element launchElement(){ return (shadow);

passing parameter/input data to custom elements in DART

流过昼夜 提交于 2019-12-02 04:39:34
I created a custom element, and want to send data / parameters to it: my element code is: class SaveBtn extends HtmlElement { static final tag = 'save-button'; factory SaveBtn()=>new Element.tag(tag); SaveBtn.created() : super.created() { // Create a Shadow Root var shadow = this.createShadowRoot(); // Create a standard element and set it's attributes. var btn = new ButtonElement(); ... btn.text= this.getAttribute('data-name'); shadow.nodes.add(btn); Element launchElement(){ return (shadow); } } } The below code in the html file worked perfectly: <save-button data-name='save orders'></save

How do I get Geolocation API to work in Dartium?

微笑、不失礼 提交于 2019-12-02 04:25:07
问题 I'm trying to test in Dartium browser using the Geolocation API. In particular I try doing the following window.navigator .geolocation.getCurrentPosition() ..then((pos) { window.alert(pos.toString()); }) ..catchError((PositionError error) { window.alert("Error code: ${error.code}, Error message: ${error.message}"); }) ..whenComplete(() => window.alert("complete")) ; Ignoring the fact I'm using window.alert here, All I get is an error with the following message "Error code: 2, Error message:

How do I get Geolocation API to work in Dartium?

那年仲夏 提交于 2019-12-02 01:14:22
I'm trying to test in Dartium browser using the Geolocation API. In particular I try doing the following window.navigator .geolocation.getCurrentPosition() ..then((pos) { window.alert(pos.toString()); }) ..catchError((PositionError error) { window.alert("Error code: ${error.code}, Error message: ${error.message}"); }) ..whenComplete(() => window.alert("complete")) ; Ignoring the fact I'm using window.alert here, All I get is an error with the following message "Error code: 2, Error message: Network location provider at ' https://www.googleapis.com/ ' : Returned error code 400." However the

Dart Language: printing reports

安稳与你 提交于 2019-12-01 12:00:49
I would like to know how to print reports on Dart. Basically, this is the activity flow: User clicks "Report" button. New browser window is created. Related data gets placed in the new window. Of course that if there's any API to do that, I would use it. So far, I've tried to create a new window, add onMessage listener on it and call postMessage on the main class to send data. However, it didn't work. The message never gets to the other side (main > new browser window). Main Dart Class var reportWindow; void createReportWindow() { reportWindow = window.open("report.html", ""); } void

DART post with multipart/form-data

こ雲淡風輕ζ 提交于 2019-11-29 11:42:53
in DART lang, how to specify POST request Content-Type to be multipart/form-data My DART code is: sendDatas(dynamic data) { final req = new HttpRequest(); req.onReadyStateChange.listen((Event e) { if (req.readyState == HttpRequest.DONE && (req.status == 200 || req.status == 0)) { window.alert("upload complete"); } }); req.open("POST", "/upload"); req.send(data); } I am doing POST with a file Robert I think you should use HttpRequest.postFormData(url, data) here. Then you can use the following: FormData data = new FormData(); // from dart:html data.append(key, value); HttpRequest.request('

How do I drive an animation loop at 60fps with Dart and the web?

﹥>﹥吖頭↗ 提交于 2019-11-28 21:17:52
How do I drive an animation loop or game loop at 60fps in a Dart web application? Use window.animationFrame , the Future-based cousin of the traditional window.requestAnimationFrame . Dart has been shifting to use Future and Stream as more object-oriented ways to handle asynchronous operations. The callback-based (old 'n busted) requestAnimationFrame is replaced by the Future-based (new hotness) animationFrame . Here is a sample: import 'dart:html'; gameLoop(num delta) { // do stuff window.animationFrame.then(gameLoop); } void main() { window.animationFrame.then(gameLoop); } The signature of

How do I dynamically add a stylesheet using Dart?

柔情痞子 提交于 2019-11-28 10:25:59
I know in Javascript how to dynamically add a stylesheet. This can be done using the following code: var sheet = document.createElement('style'); But when I try the same using Dart ( https://www.dartlang.org/ ), like this: CssStyleSheet sheet = document.createElement('style'); Then the Dart-editor tells me "A value of type Element cannot be assigned to a variable of type CssStyleSheet" . I also tried it like this: CssStyleSheet styleSheet = new CssStyleSheet(); But that gives me the warning "The class CssStyleSheet does not have a default constructor" And this: CssStyleSheet sheet =

extendTag in Dart custom element

左心房为你撑大大i 提交于 2019-11-28 10:15:10
问题 from this link in javascript, customs element extending button is made as: var MegaButton = document.registerElement('mega-button', { prototype: Object.create(HTMLButtonElement.prototype), extends: 'button' }); <button is="mega-button"> I tried making the same using dart, by this code: class MegaButton extends ButtonElement { static final tag = 'mega-button'; factory MegaButton()=>new Element.tag('button', tag); MegaButton.created() : super.created() { var shadow = this.createShadowRoot();

DART post with multipart/form-data

寵の児 提交于 2019-11-28 05:32:01
问题 in DART lang, how to specify POST request Content-Type to be multipart/form-data My DART code is: sendDatas(dynamic data) { final req = new HttpRequest(); req.onReadyStateChange.listen((Event e) { if (req.readyState == HttpRequest.DONE && (req.status == 200 || req.status == 0)) { window.alert("upload complete"); } }); req.open("POST", "/upload"); req.send(data); } I am doing POST with a file 回答1: I think you should use HttpRequest.postFormData(url, data) here. Then you can use the following: