dart,paper-elements , Dart - paper button - how to add onclick script

Dart - paper button - how to add onclick script


Tag: dart,paper-elements

I create a paper button dynamically (and add it to the dom tree). Looks fine, but I need to add an action to it by catching an "on pressed" event:

  void add_button(String butName){

    PaperButton NewPaperButton=new PaperButton();
    NewPaperButton.onClick=callback();<<<<???? what do I do here?? onMouseDown?



You can create the callback like this:

void onButtonClicked(Event event, var detail, Element target) {
  // do something

And you can set up the listener like this:



How to migrate to Polymer and PaperElements 1.0 using pubspec.yaml

I have found Migration guide (https://www.polymer-project.org/1.0/docs/migration.html). My Dart project does not use bower but pubspec.yaml and when I changed dependencies version for PaperElements I get message: paper_elements has no versions that match >=1.0.0 environment: sdk: '>=0.8.10+6 <2.0.0' dependencies: browser: '>=0.10.0+2' code_transformers: any core_elements: '>=0.6.0' dnd: any logging: '>=0.9.3' paper_elements: '>=1.0.0'...

How to parse a String of “hh:mm:ss.SSS” into a DateTime

The format of "new DateTime.now()" will print following output: 2015-05-20 07:34:43.018 By having only the time as a String in the correct format ("07:34:43.018"), how do I parse the time to a DateTime object? The usage of the intl package does not support the mentioned format AFAIK....

Dart Polymer: Creating PaperDialog with CoreAnimatedPages displayed incorrectly in Firefox

I use Dart Polymer PaperDialogs containing CoreAnimatedPages. The idea is to have popups in which you can click through multiple option views. Example repository available at: https://bitbucket.org/neogucky/polymer-dialog-problem/ DialogView: view.html <link rel="import" href="packages/polymer/polymer.html"> <link rel="import" href="packages/paper_elements/paper_button.html"> <link rel="import" href="packages/paper_elements/paper_dialog.html"> <link rel="import"...

How to create json encodable classes in dart

This question is related to this post. I tried the following code: import 'dart:convert'; /*server side Post class */ class Post { int post_id; String title; String description; DateTime posted_at; DateTime last_edited; String user; String editor; int up_votes; int down_votes; int total_votes; String links_to; List<String> tags = new List(); Post.fromSQL(List...

using dart route package url got error 404

Here's my main.dart: import 'dart:html'; import 'package:route/client.dart'; import 'urls.dart'; void main() { var router = new Router() ..addHandler(homeUrl, showHome) ..addHandler(galleryurl, showGallery) ..listen(); HttpRequest.getString("home.html").then((html){ querySelector("#container").innerHtml = html; }); } void showHome(String path){ HttpRequest.getString("home.html").then((html){ querySelector("#container").innerHtml = html; }); } void showGallery(String path){ HttpRequest.getString("gallery.html").then((html){...

JsFunction.apply doesn't work while JsObject.callMethod does work (dart)

I have this often, that JsFunction.apply doesn't work like I would expect. Consider this example: import "dart:js"; import "dart:html"; void main() { var div = querySelector('div'); var span = new SpanElement()..text = "hello world"; var js = new JsObject.fromBrowserObject(div); js["appendChild"].apply([span]); // this one does work: // js.callMethod("appendChild", [span]); } I...

In the dart:io library, why would one want to set runInShell: true when calling Process.run?

What functionality does this offer? Furthermore, how does the process get called when runInShell is set to false? What's the difference?

Failed to load dartium when running test

I'm running dart test using test library. pub run test -p dartium When this command is executed I'm getting below error, I have dartium and dart sdk downloaded and in system path. Failed to start Dartium: No such file or directory Command: dartium --user-data-dir=/tmp/dart_test_cwDGGO ...

Refuse to load JS in Dart

In my web page for Dart amount this script: <script src="https://test.net/test/test.js"></script> but when you launch the application it gives me the following error: Refused to load the script 'https://test.net/test/test.js' because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src'...

paper-ripple is listening to click events outside of its container

I'm trying to create a simple ripple effect for a card in my app. It works great, but it is also responding to mouse events outside of its container: Code looks like this: <dom-module> ... <template> ... <paper-material> <div class="wrapper">...</div> <paper-ripple></paper-ripple> </paper-material> ... </template> </dom-module> I don't quite see why...

What is the proper way to remove a stream from stdout so that another stream may be added?

I am starting a process in Dart that attaches its stdout stream to stdout so that the results can be printed to the terminal like so: Process.start(executable, ['list','of','args']).then((proc) { stdout.addStream(proc.stdout); stderr.addStream(proc.stderr); return proc.exitCode; }); However, once this completes I would like to start a new process and begin this again...

Google Cloud Messaging in dart

I'm trying to connect to the Google Cloud Messaging with this code in dart senderIds.add("api-project-testid"); chrome.gcm.register(senderIds).then(registerCallback); but I have this error: Exception: Uncaught Error: Profile was not signed in. I think that the error arises from the fact that chromium is not connected with any account. Does anyone know how...

Type Error when using JwtSessionHandler - dart

I have a problem with the dart types when using the JwtSessionHandler. I wanted to integrate user authentication and sessions using this example application from the shelf_auth git repository as a guide. Unfortunately I get an error when running the application (no syntax errors are detected before running the application)...

How to access detail from core-signal event in polymer.dart?

I am working on a web app in polymer.dart. When I use core-signal, I am unable to access the detail. Here's some of the code that I'm using... main_app.dart class MainApp extends PolymerElement { onClick(Event event, var detail, Node sender) { print('button clicked'); fire("core-signal", detail:{'name':'button-click', 'data':0}); } ready() { super.ready();...

Dart Pub greater than and less then mardown issue

Having an issue with the display of "<" and ">" using markdown's back-tick code syntax in Dart pub? Not sure how to achieve: Future<bool>. If I write that as I have done here, it comes out as: Future&lt;bool&gt;, as found here: https://pub.dartlang.org/packages/functional_behaviour_tree Have also noticed that where packages were fine...

convert HttpHeader to Map

When using dart on the browser (no dart:io) is there a ready to use way, to convert the string returned by req.getAllResponseHeaders(), where req is a HttpRequest, into a dart Map. I was a bit surprised by the fact that there is no ready method here, since all http related...

Does the dart VM impose restrictions on the stack memory size of a native extension?

I'm learning to write a native extension and I noticed an odd occurrence. When I allocate a multidimensional array and access it like so: (excuse any messy C code and bad practices I might be using unless they're likely the cause of my error. My C is not-so-great) int table[rows][cols];...

Block until field is initalized

trying to block the execution within a setter until the filed value changes and i know that it will change within a few microseconds, to demonstrate the problem i wrote: import 'dart:async'; void main() { new Timer.periodic(new Duration(seconds:1),(t)=>print(Store.x)); new Timer.periodic(new Duration(seconds:3),(t)=>Store.x='initalized'); } class Store{ static String _x = null; static...

How to sort map value?

I have this map: var temp= { 'A' : 3, 'B' : 1, 'C' : 2 }; How to sort the values of the map (descending). I know, I can use temp.values.toList()..sort(). But I want to sort in context of the keys like this: var temp= { 'B' : 1,...

Different server behavior from CURL and browser

My server behaves differently when I do a login request with CURL and from the browser. When doing the following curl request: curl -i -X POST 'http://localhost:8080/login' -d 'username=fred&password=blah' -H 'content-type: application/x-www-form-urlencoded' I get the expected result in form of: However when doing the same (or so I think) request...

Questions about using Futures and Completers

Hey have I read all I can find about futures, but I would like some more advice on proper usage. I am writing an API library, that bridges the gap between HTTP Requests and the app. So I use the future returned by HTTP in most cases, however sometimes the...

Abstract methods in Dart

I'm implementing an inheritance hierarchy in which derived-class construction consists only of a call to the base-class constructor. The base-class constructor then calls method(s) implemented only in the derived-class. I have a basic implementation, but DartEditor of course complains about the missing methods in the base class. How can I...

Intercept dialog from and read the contents

I use this code to intercept a dialog from a webview but I can not see the content or interact with it: Element webview= querySelector("#webview"); Map<String,String> map=new Map(); map["src"]=urlWebView+user; webview.attributes.addAll(map); querySelector("#webview_cont").style.visibility="visible"; window.addEventListener("dialog",(Event e){ //Use window or webview returns the same result e.preventDefault(); ... //What should I do here ?? }...

How to set callback when