dart-html

Using Dart for HTML5 app, but want to load a file from the server-side

此生再无相见时 提交于 2019-12-13 01:08:53
问题 I'm new to Dart, and trying to create my first Dart web game. Sorry if I missed an answered question related to this. I did search, but wasn't having much luck. To load a level, I would like to be able to read in a text file with the level data, then process that and use it to build the level. Unfortunately, I am running into the issue where dart:io and dart:html can not both be loaded if you want to use the File() object. From what I can tell, dart:html's File() object is client-side, so

Loading HTML in the current dom and execute a loaded script

五迷三道 提交于 2019-12-12 01:58:43
问题 In javascript I created a loader for a wizard. I talk about a single page with a wizard section. Every (new) sequence state of the page loads a HTML section from the server into the wizard dom section of the page and executes a script. The script for this sequence state is also loaded. I have seen a lot of discussion about loading Dart scripts and this blog post from Sett Ladd. I understand I can only load Dart scripts in isolates. My questions: Can I create the above like wizard in Dart?

Dart create and transform an SVG path

假装没事ソ 提交于 2019-12-11 23:24:32
问题 I recently started programming in Dart (www.dartlang.org). Now I try to display an SVG path and scale the path to fit in a div of 20px * 20px; I do have a path, and I did create a transformation matrix, but how does one apply the matrix to the path? My code so far: // create an svg element SvgSvgElement svg = new SvgSvgElement(); // create a path PathElement path = new PathElement(); // draw something path.setAttribute('d', myPath); // add the path to the svg svg.append(path); // add the svg

Is it possible to use querySelector() on a dynamically created element?

拈花ヽ惹草 提交于 2019-12-11 22:21:18
问题 I'm using appendHtml() in a loop to dynamically add li elements (with unique IDs in the string) to a ul. When I need to access these dynamically created li elements by their IDs to, for example, create nested lists, querySelector() returns null. If I should be able to do this, then there could very well be bugs in my code. But I want to make sure this is the case. 回答1: It doesn't matter how elements are added, if the are part of the DOM querySelector can find them. 来源: https://stackoverflow

String comparison not working for text received from web scraping

北城余情 提交于 2019-12-11 17:57:25
问题 I am comparing text received from web scraping with hardcoded text in my code. The two texts are identical. No Capital-Small error. They are identical but still the comparison fails. I am sharing a part of my code. The problem is between the lines 47 to 56. Between these lines, the string comparison in if else blocks fails. The values provided for these blocks are perfectly fine values which should ideally satisfy the condition. The if condition at 49 gets satisfied for some reason and the

Why is RenderingContext.drawElements clearing the screen before it draws?

陌路散爱 提交于 2019-12-11 10:27:00
问题 Is RenderingContext.drawElements correct when it clears the screen before it draws? Consider these screenshots that show a step across a call to drawElements with the object already drawn being erased. 回答1: WebGL effectively clears the screen after the page has been composited. When you're stepping through stuff one line at a time it's going to be composited every time you stop. If you don't want it to be cleared ask for preserveDrawingBuffer: true when you create the WebGL context as in gl =

Moving elements by dragging in Dart

烈酒焚心 提交于 2019-12-11 00:56:46
问题 I am trying to move an element using drag and drop. I want to be able to drag and element to a different location, and when I drop it, the element moves to the dropped location. Super basic, and nothing fancy. This is what I have so far: html: <input type='button' id='drag' class='draggable' value='drag me' draggable='true'> Dart code: Element drag = querySelector('.draggable'); drag.onDragEnd.listen((MouseEvent e) { drag.style.left = '${e.client.x}px'; drag.style.top = '${e.client.y}px'; });

drawImage with ImageElement

夙愿已清 提交于 2019-12-10 19:16:09
问题 Working: (document has a img tag with id="img" src="img.png", and it works) void test() { ImageElement img = query('#img'); context.drawImage(img, 0, 0); } Not Working: void test() { ImageElement img = new ImageElement(src: 'img.png'); context.drawImage(img, 0, 0); } so, why can't I use 'new ImageElement' instead of 'query' from the document ? 回答1: The problem is that the image hasn't loaded by the time you call drawImage (as opposed to when it is embedded in the page and loads before the

In Dart, if I listen to a click event with two listeners, how do I know which happens first?

只愿长相守 提交于 2019-12-08 19:49:35
问题 If I write the following Dart code, how do I know which click handler happens first? main() { var button = new ButtonElement(); var stream = button.onClick.asBroadcastStream(); stream.listen(clickHandler1); stream.listen(clickHandler2); } Let's say I'm in other code that doesn't know anything about the first two click handlers, but I register another one. Can I know that the stream has two listeners? Can I pause or cancel all other subscribers? If I write button.onClick.asBroadcastStream()

What's the difference between “dart:html” and “dart:dom” package?

回眸只為那壹抹淺笑 提交于 2019-12-08 16:35:21
问题 I'm starting with some of the Dart examples. Then I wanted to query the DOM with document.query('#someId') as described here, but it seems there was no query method in document. Also creating a new element by `new Element.tag('p') doesn't work. Then I figure out that it will work, when I change the imported package from dart:dom to dart:html . But using both of them gives me a bunch of duplicate definition of _XYZ . So I wonder: what's the difference between dart:html and dart:dom package