FAQ Database Discussion Community


Stuck with initialize package (Dart)

dart
I have been trying this the whole day: I use initialize in several places in my library and then I have some example code in several HTML+Dart files. For one set of html+dart it works for another it does not - it simply never calls the init methods even when...

Resize when selecting inside the dialog

dart,polymer,paper-elements
resizeable_dialog.html <link rel="import" href="../../packages/polymer/polymer.html"> <link rel="import" href="../../packages/paper_elements/paper_dialog.html"> <link rel="import" href="../../packages/paper_elements/paper_button.html"> <link rel="import" href="../../packages/paper_elements/paper_tabs.html"> <link rel="import" href="../../packages/paper_elements/paper_tab.html"> <link rel="import" href="../../packages/paper_elements/paper_icon_button.html"> <link rel="import"...

Polymer Dart, global variables and data bindings (observable)

dart,dart-polymer,shadow-dom
I read Polymer API developer guide, but unfortunately it has examples only for JavaScript developers. Some examples I try to port into Dart, but in this case I get fail. Please, go to https://www.polymer-project.org/0.5/docs/polymer/polymer.html#global (Section Supporting global variables). Here is a clip from the documentation: elements.html <polymer-element name="app-globals"> <script> (function()...

Is it possible to change the default build directory in Dart?

dart
When I run pub build, pub puts the compiled app into build/web. Is it possible to configure my pubspec.yaml file to change the default output directory to, say, prod? EDIT: I'm trying to avoid having to use the --output switch each time....

Using bootstrap navbar in bootjack

twitter-bootstrap,dart,bootjack
I'm using twitter bootstrap's CSS to create a standard bootstrap navbar and then calling Dropdown.use(); which makes the navbar work automagically. When I re-size the page or view it on mobile, the navbar displays this menu button which does nothing when you click on it. How would I go about...

How to use multiple isolates to serve requests

dart,dart-io,dart-isolates
How can a Dart server be set up to use all available cores for in coming requests (e.g. by using multiple isolates to serve requests)?

Using dart discoveryapis_generator on webapp?

dart,google-cloud-endpoints
Can't use my model file generated with the discoveryapis_generator. It ask for a http.client to be used, but it's from dart:io, and i m trying to use it in a web app static YoupipeApi api = new YoupipeApi(new http.Client()); //cant work on webapp Failed to invoke tokenLoaded callback: Unsupported operation:...

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

javascript,dart,dart-js-interop
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...

Sum of integer values of a Future

dart,future,dart-async
I'm trying to parse a HTML document, get all the image-sources and then add the size of all pictures together. Parsing the document works fine, so does getting the image-sources and getting their size. main(){ print("Please input an URL"); var url = stdin.readLineSync(); getImageUrls(url).then((list) { list.forEach((imageUrl) { getImageSize(imageUrl).then((r) { print("$imageUrl,...

Direct access to @observable variable from other object

dart,dart-polymer
Is it ok to access @observable variable directly from other object, without making it @published and defined as polymer element attribute? For example, I have a custom element, defined without any data binding: <my-element id="my"></my-element> and, on response to some external event in it's parent element, I can do something...

Cross-Domain issue in Chrome possibly b/c of strange Dart HttpRequest behavior

ajax,google-chrome,amazon-s3,dart,cors
I know guys, there are tons of questions about the Amazon S3 Buckets and CORS. But please, let me add mine. So I'm writing an application in Dart and I am performing an ajax request to a resource which is hosted on S3. I originally wanted to grab the first...

Callback in Dart when the page is fully loaded

javascript,html,dart,polymer
You may know that I totally fell in love with Dart and Polymer and once again, I have a question addressing those two technologies. My application is a fairly compex polymer app written in Dart. There are some sort of "pages" whereas a page is shown once the user performed...

Determine browser's default text highlight color using JavaScript or Dart

javascript,html,css,browser,dart
The browser's default text highlight (selection) background color can be overridden, e.g.: ::selection { background: #ffb7b7; } And the color is browser/OS specific. Is there a way to read the browser's default value using JavaScript or Dart?...

Incompatibility between the Dart shelf and rpc packages? ('access-control-request-method' header)

dart,dart-shelf
There seems to be an incompatibility between the shelf and rpc packages. In rpc [0.4.1] config/api.dart: The handleHttpOptionsRequest expects the 'access-control-request-method' header to be a List: Future<HttpApiResponse> handleHttpOptionsRequest( ParsedHttpApiRequest request) async { var requestedHttpMethods = request.headers['access-control-request-method']; List<String> allowed = []; assert('OPTIONS'.allMatches(request.methodKey).length == 1); if (requestedHttpMethods != null) { requestedHttpMethods.forEach((httpMethod) {...

Dart import package:polymer/polymer.dart error

dart,dart-polymer,dart-pub
I'm trying to create my own element with Polymer, but i can't import polymer package. Why it throws error: "Target of URI doesn't exist"? In Tools Output window I found 404 error. And my pubspec.yaml: name: polymer1 description: A sample web application dependencies: browser: any polymer: ">=0.15.1 < 0.17.0" ...

Dart equivalent of Array.prototype.map()?

javascript,arrays,dart
I try to get the id's from List of Maps in Dart. In JavaScript it would be something like this: var list = [{id:3, name:'third'}, {id:4, name:'fourth'}]; var result = list.map(function(x){return x.id;}); This should give the result [3, 4] Is there a simple way of doing this in Dart? So...

postgresql open connection and execute more then one command

postgresql,dart,dart-async
I want to do the following two insert operations using the postgresql driver for dart. The code below works! INSERT INTO posts( title, description, posted_at, last_edited, "user", editor, up_votes, down_votes, flag, links_to) VALUES ('test title', 'test description', now(), now(), 'dartUser', 'dartUser', 0, 0, 'healthy', 'http://google.com'); INSERT INTO atatched_tags( post_id, tag)...

using dart route package url got error 404

routes,dart
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){...

Creating a capitalize Method in Dart

dart,capitalize
I am trying to create a method in dart but have run into a wall. I was looking at how .toUpperCase(); and .toLowerCase(); were done. The method that I am trying to create is .capitalize(); I would like to call this method like this String hello = "WORLD".capitalize(); //World Here...

How to remove diacritics (accents) from a string?

string,dart,diacritics,unaccent
I'm trying to convert some strings that are in Czech, Spanish, French etc. I'd like to take out the accent marks in the letters while keeping the letter. (E.g. convert é to e, č to c, Ž to Z, ñ to n) What is the best way to achieve this?...

Order by query using dart and postresql

postgresql,dart
When running this query using dart and the postresql driver getPost(int limit, int offset, String order_by){ connect(uri).then((conn){ conn.query('''select * from posts order by @order_by limit @limit offset @offset''', {'limit': limit, 'offset': offset, 'order_by': order_by}) .toList() .then((rows){ print(rows); }) .whenComplete(() => conn.close()); }) .catchError((err) => print('Error in getPost: $err')); } I...

Block until field is initalized

dart
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...

Dart data binding from a parent custom element to attributes of a child custom element

dart,dart-polymer
Here is a problem that cropped up today when I updated to the latest Dart libs. The child custom element is a combo box. The parent custom element fills it with a varying list of strings. // child HTML <polymer-element name="bx-icombo" attributes="aLabel aList aSelected"> <template> <div class='outr' flex layout horizontal...

Alert dialog from was blocked

javascript,webview,dart,google-chrome-app
Dart doesn't show the alert dialog when I use a webview and show this error: : An alert dialog was blocked. (extensions::webViewEvents:225) : A confirm dialog was blocked. (extensions::webViewEvents:225) Does anyone know how to bypass the problem or how to catch the error? Thanks. Sorry for my bad English. Edit...

Parallel.run syntax

javascript,dart
I just watched this introduction from the Dart Summit. During the talk, this code was put up: => new List.generate(100, (y) => renderLine(y)); I'm pretty sure I understand that line. The arrow function is new to me but okay - it looks a little coffee-esque. The point though, was changing...

Set custom header in Dart's HttpRequest

dart,httprequest
I need to set a custom header in my HttpRequest in order to use encryption in an S3 bucket. The header which I want to set the header x-amz-server-side​-encryption​-customer-algorithm but I always get an SyntaxError: An invalid or illegal string was specified. 'x-amz-server-side​-encryption​-customer-algorithm' is not a valid HTTP header field...

Can I force unoptimal logical condition checking?

dart
Is it possble to change the whay the logical or || statement is executed in dart. For example. I have the functions foo() and boo() which have a return type of bool. If i write (foo() || boo()) ? /* A */ : /* B */; and foo() returns true...

Checking, if optional parameter is provided in Dart

syntax,dart,syntax-error,questionmark
I'm new to Dart and just learning the basics. The Dart-Homepage shows following: It turns out that Dart does indeed have a way to ask if an optional parameter was provided when the method was called. Just use the question mark parameter syntax. Here is an example: void alignDingleArm(num axis,...

Add delete item button - ToDo App - Dart

dart
I'm very new to dart, so don't judge me. :)) I just started to write a simple ToDo App in Dart. I want to add a button to the item, so i can delete it from the list. I add the button successfully, but don't get the click event working....

How to test Dart Polymer elements using the new Test library?

unit-testing,testing,dart,dart-polymer
How do you test Polymer elements using the new test library? Using the new test library to test a Dart Polymer element, I build my_element_test.html as prescribed. Please see my repo: polymer-dart-testing. No Polymer Initiation Passes my_element_test.html and my_element_test.dart (commenting out Polymer initiation) passes tests as expected: my_element_test.html <!doctype html>...

What is the best way to set the default instance for a final private field with optional parameter?

dart
Given a class with final private field _bar: class Foo() { final Bar _bar; Foo({Bar bar}) : _bar = bar { //error: list cannot be used as setter, it is final _bar = new Bar(); } } Attempting to set it in the parameter list results in this error //error:...

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

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

How to set callback when