FAQ Database Discussion Community


Get current script path or current project path using new test runner

dart
I am porting old vm unittest files using the new test package. Some relies on input files in sub directories of my test folder. Before I was using Platform.script to find the location of such files. This works fine when using $ dart test/my_test.dart However using $ pub run test...

dart wait for inner Future

mysql,dart
I'm trying to execute some queries which have a reference as foreign keys on each other, so I have to wait until the outer future is finished. This algorithm is placed inside a function which returns a future. Future<List<int>> newEntry(Session session) { bool success = true; List<int> error = Helpers.formatJsonAndEncodeUtf8(...

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

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

c,memory,dart,dart-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];...

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

Weird DartEditor behavior / bug?

dart,dart-editor
I'm working on a little website using dart. I have one project for the server, and another for the client app (see picture below) In the server app I serve the client app from the client project like this runServer() { var staticHandler = createStaticHandler(r"C:\Users\Lukasz\dart\linkShepherdClient\web\", defaultDocument: 'linkShepherd.html',serveFilesOutsidePath: true); var handler...

Dart: Create method from string

javascript,dart
I've been trying to create methods dynamically from strings using Dart to no avail. String example: "(String str) => return str.length;". The idea is to allow users to create their own functions to apply to a given string. The only thing I've found is NoSuchMethod which does not seem to...

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

Error 42601 using postgresql and dart

postgresql,dart
I get the error 42601 when using postgresql I created the table using pgAdmin. The autogenerated code looks as follows. -- Table: posts -- DROP TABLE posts; CREATE TABLE posts ( post_id bigserial NOT NULL, title character varying(150) NOT NULL, description character varying(500), posted_at timestamp with time zone, last_edited timestamp...

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

Listening for event in Dart via JQuery “on” with dart:js

jquery,dart,bootstrap
I use dart call bootstrap modal window,and I want register a callback function ,but found the same problem other person mentioned before. here is jQuery code: $('#myModal').on('hidden.bs.modal',function (e) {....}) How can I write the same code in dart with dart:js, because package:js is deprecated; so I can't use callback function...

“Refused to load the image” in a Chrome App

dart,google-chrome-app,content-security-policy
I have this problem in dart Refused to load the image 'https://**.png' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:". when try to set src in image element ImageButtonInputElement button = new ImageButtonInputElement(); button.className="button_element"; button.src=el["imageUrl"]; //like "https://**.png" whit this manifest.json "content_security_policy":"img-src https://server.example.org" Someone would know...

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

Using resumable.js from Dart

dart,dart-js-interop,resumablejs
I am trying to use resumable.js from Dart with this code: var rs = new JS.JsObject(JS.context['Resumable'], [new JS.JsObject.jsify({ 'target':context.server+'/upload' })]); files.forEach((file) { rs.callMethod("addFile",[file]); }); files variable is defined as List<File> (dart.html.File). When I check properties of rs object with these two lines: JS.context["console"].callMethod("log",[rs['opts']]); JS.context["console"].callMethod("log",[rs['files']]); I find that rs.opts are initialized...

How to debug a Dart client Side application using IntelliJ Idea Community Edition?

debugging,intellij-idea,dart
I would like to know if it is possible to debug a client side web application using IntelliJ Idea 14.1+. Until the moment I only have found some tutorials for Webstorm and IntelliJ Idea Ultimate Edition....

Dart Mirrors in JS: type '_ListConstructorSentinel' is not a subtype of type 'int'

dart,dart-mirrors,dart2js,dart-sdk
The following code executes fine on the VM, but fails with "'_ListConstructorSentinel' is not a subtype of type 'int'" when converted to javascript via Dart2JS. I'm using "pub run test -p chrome " to run the code. import "dart:mirrors"; main() { TypeMirror tm = new TypeToken<List<String>>().typeMirror; (tm as ClassMirror).newInstance(const Symbol(""),...

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

Intercept dialog from and read the contents

webview,dialog,dart,google-chrome-app
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 ?? }...

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

Dart + Polymer, how to bind to programmatically generated elements, textarea, select, optgroup

data-binding,dart,polymer
I'm trying to create a form Polymer component where form elements are generated on the fly. I've looked, and so far the only way to bind the value attribute is by using .injectBoundHtml. This does not work with all component types, I'm trying to bind the value of a <textarea>,...

Why doesn't the dart2js compiler convert 64-bit integers to IEEE 754 FP numbers?

javascript,integer,dart,precision
I've been reading that the dart2js compiler doesn't support 64 bit integers. Is this because javascript doesn't have a representation for 64-bit integers and stores all numbers as 64-bit double precision values? If so, couldn't integer values simply be converted to the representation? If that is not the case, why...

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

Error after compiling Polymer Dart to JS. (The “smoke” library has not been configured)

dart,dart-polymer,dart-pub,dart2js
Аfter compiling Dart code (which use Dart Polymer) to JS. I get the following error: Uncaught Exception: The "smoke" library has not been configured. Make sure you import and configure one of the implementations (package:smoke/mirrors.dart or package:smoke/static.dart). Sometimes the message was: No elements registered in a while, but still waiting...

Dart Pub greater than and less then mardown issue

dart,markdown,publish
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...

How can I tell the dartanalyzer what kind of Element the selected object is?

object,syntax,types,dart
I have the code if(querySelector('#username').value!="") and it is working. But Darteditor warns me, that the getter 'value' is not defined for the class 'Element'. I know, that what the querySelector returns is an InputElement and therefore, my question is only for reasons of beauty and to remove the warnings. How...

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

Setting up play framework and dart for development and debug

eclipse,playframework-2.0,dart,dart-pub,typesafe-activator
I'm developing a relatively simple web app using play framework for the server and dart for the client. I'm using eclipse. Development and debug are fine on their own but how do to get them to work together? Play has its own web server (activator) that knows how to load...

Choosing between package:html, dart:html, dart:io (class HttpClient) and package:http APIs to fetch HTTP resources

android,dart,httprequest,api-design,dart-pub
I realized that currently there are at least three "official" Dart libraries that allow me to perform a HTTP request. What is more, three of those libraries (dart:io (class HttpClient), package:http and dart:html) have each a different, incompatible API. As of today, package:html does not offer this functionality, but on...

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

Add extra headers to websocket connection from browser in Dart

security,authentication,websocket,dart,dart-html
I'm trying to establish an authenticated websocket connection, and this question is a sibling to similar question for server part. How I can add extra headers when I establish a websocket connection from browser? I'm trying to use dart:html's WebSocket object to connect to server requiring a header authentication: containing...

Make function to return custom stream

dart,dart-async
Is it possible to create a function that returns a custom stream and handles it like this? user.logIn('owner', '1234') .listen( success (Object user) { print(user); }, error: (Object user, Object error) { print(error); } ); ...

Set selected of Paper-Tabs

dart,dart-polymer,paper-elements
I am trying to select a paper-tab based on it's data-id attribute. I have the element but I cannot changed to selected property of the inner_tabview. I have a Polymer: <paper-tabs id="inner_tabview" noink="true"> <template repeat="{{item in tabNames}}"> <paper-tab data-id="{{item['id']}}"><h3>{{item['name']}}</h3></paper-tab> </template> </paper-tabs> And some Dart code behind it: selectTab(itemId) { PaperTab...

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

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

Dart pub get generates link to packages in each folder and subfolders

dart,dart-pub
I try to avoid Dart to generate symbolic links (to packages) in each folder/sub-folder. For example, in pubspec.yaml I add polymer package and run pub get. After that I got: Now each folder has packages symbolic link! As I understand it's because to ensure that we can use package:.. statement...

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

On which version is based Polymer Dart?

dart,polymer,dart-polymer
What the version Dart Polymer use (of the original Polymer project, eg 0.5 or 0.8 etc)? And where can I see it? I mean on which version Polymer.dart is based concerning the mainstream Polymer.js. For example recently Polymer (JS version) released 0.8 version with some breaking changes and features. I...

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

Different server behavior from CURL and browser

session,curl,dart
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

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

How do I programatically select and disable a PaperButton?

dart,dart-polymer
I'm trying to migrate from Bootstrap to Polymer/Paper and I've got a lot of situations where I have to enable/disable buttons that were previously accessed as ButtonElements and then .disabled=true/false. So for example I've got a paper button I'm trying to access and enable/disable via querySelector as such: PaperButton nextWeekButton...

Failed to load dartium when running test

dart,dart-html,dart-unittest
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 ...

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

dart,dart-polymer,paper-elements
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'...

Google Cloud Messaging in dart

dart,google-chrome-app,chromium,chrome-gcm
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...

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 set callback when