Google DART: How to get clientWidth property with dart:html

Google DART: How to get clientWidth property with dart:html

#import('dart:html');

class HTMLclientWidth {

}

void main() {

/* This code works with dart:html */

DivElement myDiv = new Element.tag('div');
myDiv.id = 'TEST';
myDiv.innerHTML = 'Test div for testing dart:html:clientWidth';
myDiv.style.setProperty('background', '#ff0000');

window.document.body.nodes.add(myDiv);

Future <ElementRect> re = myDiv.rect;

re.then((r) {
num myDivClientWidth = r.client.width;
myDiv.innerHTML += '<br/> clientWidth :: ' + myDivClientWidth.toString();
});
}

by Moisés Belchín

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s