FAQ Database Discussion Community


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

How to create json encodable classes in dart

json,dart,to-json
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...

Error 42703 when connecting to postgresql database with dart

postgresql,dart
To test my connection to the database I wanted to simply add some hard coded data to one table. Here is my approach. In the main.dart file there are only 2 problem related rows DatabaseUtility dbUtil = new DatabaseUtility('postgres', 'kewoziwa', 'auctionDB'); dbUtil.insertIntoUsers({'login': 'dartUser', 'password': 'passMePlease'}); In the first row I...

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

Serving content dynamically using the directory parameter for GET requests - shelf package dart

get,dart,dart-shelf
The code snippets below come from a server serving a get request Server snippets 1) io.serve(handler, InternetAddress.LOOPBACK_IP_V4, 8080).then((server) { print('Listening on port 8080'); }).catchError((error) => print(error)); 2) Router routes = new Router() ..get('/newest', handler.handleNewest) ..get('/anonymous', handler.handleAnonymousGetRequest) ..post('/anonymous', handler.handleAnonymousPostRequest); 3) shelf.Response handleNewest(shelf.Request request){ print('got request for newest'); return new shelf.Response.ok('sample content...

Dart Polymer: Creating PaperDialog with CoreAnimatedPages displayed incorrectly in Firefox

firefox,dart,polymer
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"...

Generate static accessors by name

dart
Suppose i had this class: abstract class DynamicallyAccessible{ operator [](String key){ throw 'DynamicallyAcessible [] operator is not implemented'; } operator []=(String key,Object value){ throw 'DynamicallyAcessible []= operator is not implemented'; } call(String methodName,List<Object> params){ throw 'DynamicallyAcessible call method is not implemented'; } } and this class which extends the above:...

Dart - Polymer Unit Testing. Not able to reference dom elements after click event

dart,polymer,dart-polymer
Not able to reference dom elements. Most of the test case works except for the last expectation in ClickSignInButton when I want to make sure I can evaluate error message div when form is submitted without any data. expect(document.querySelector('qme-header').shadowRoot .querySelector('#headerErrorDiv'), isNotNull); always fails and headerErrorDiv is null even though its...

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()...

Type Error when using JwtSessionHandler - dart

types,dart,jwt
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 parse a String of “hh:mm:ss.SSS” into a DateTime

parsing,date,datetime,dart
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....

How to set callback when