Skip to main content

Significant Dart Editor Release Brings Back String Plus Operator

Dart Editor has a new build. This is a significant release with a long list of breaking changes. You are urged to update your Dart code accordingly. 

Due to popular demand, the Dart team brought back the plus operator for string concatenation. That change has now landed in the Editor. Before this release, using + to concatenate strings produced this
error:







Now, you can use + for concatenation. The concat() method has been deprecated:













There are numerous other changes in the core libraries, the dart:html library, and the dart:io library. 
Eric Clayberg fills us in on the details of this release:

A new Dart Editor build is available at www.dartlang.org/editorChanges include:
  • New analyzer available via experimental preference.
    (work in progress, all features not enabled yet).
  • Package root preferences removed in favor of --package-root cmd line option.
  • Reduced heap usage by ~25%.
  • Fixed a memory leak which could eventually consume 10% of the heap.
Breaking Change List:
  • Wide-ranging changes:
    • All HTML callback APIs have been converted to Futures (with a few exceptions: RtcPeerConnection.getStats, Window.setImmediate, Window.requestAnimationFrame, Window.openDatabase, WorkerContext.openDatabase, and MutationObserver).
  • Name/functionality changes in corelib:
    • IOSink interface has changed. It now implements StringSink with the methods write,writeln, writeAll and writeCharCode for writing strings to an IOSink. As writing strings to an IOSink requires an encoding theIOSink now has en encoding property. Depending on what the IOSink is connected to this encoding property might be mutable. For the IOSink on HttpClientRequest and HttpResponse the encoding is determined from the "charset" parameter of the "Content-Type" header. The default in this case is ISO_8859_1.
      To match the write prefix of the methods on StringSink the add (for writing bytes) have been renamed to writeBytes and addStream has been renamed to writeStream.
    • StreamSink becomes EventSink, signalError becomes addError
    • num.floor(), .ceil(), .truncate(), .round() return integers now (even on doubles).
    • xMatching -> xWhere:
      Iterable.firstMatching -> Iterable.firstWhere
      Iterable.lastMatching -> Iterable.lastWhere
      Iterable.singleMatching -> Iterable.singleWhere
      Stream.firstMatching -> Stream.firstWhere
      Stream.lastMatching -> Stream.lastWhere
      Stream.singleMatching -> Stream.singleWhere
      Collection.removeMatching -> Collection.removeWhere
      Collection.retainMatching -> Collection.retainWhere
    • Timer.repeating -> Timer.periodic
    • Set.containsAll(Collection) -> Set.containsAll(Iterable)
    • Set.intersection(Collection) -> Set.intersection(Set)
    • Duration has a private variable now and its implicit interface cannot be implemented anymore without warnings.
  • Deprecations in corelib:
    • Set.isSubsetOf deprecated, to be removed.
    • List.getRange(start, length) deprecated, to be removed.
    • Iterable.min, Iterable.max, Stream.min, Stream.max deprecated, to be removed.
  • dart:html:
    • Rect has been renamed to CssRect, RgbColor has been renamed to CssRgbColor.
    • General-purpose Rect and Point classes have been added
    • APIs exposing ClientRect now expose Rect
    • Element.client* and Element.offset* properties have now become rects as well.The old syntax is currently deprecated.
      Old:
      var top = Element.clientTop;
      New:
      var top = Element.client.top;
    • Input events are having their position properties change from clientX & clientY to a single Point field. The old syntax is currently deprecated.
      Old:
      var x = mouseEvent.offsetX;
      New:
      var x = mouseEvent.offset.x;
    • CanvasRenderingContext.drawImage(canvas_OR_image_OR_video, num sx_OR_x, num sy_OR_y, [numsw_OR_width, num height_OR_sh, num dx, num dy, num dw, num dh]) has changed to two functions with more reasonable parameters:
      void drawImage(CanvasImageSource source, num destinationX, num destinationY) and
      void drawImageAtScale(CanvasImageSource source, Rect destinationRect, {Rect sourceRect})
      CanvasImageSource is one of ImageElement, VideoElement, or CanvasElement.
      The primary reason for this change is to make the method signature more understandable, while not reducing any functionality.
    • DirectoryEntry.getFile and DirectoryEntry.getDirectory have changed function signatures and added DirectoryEntry.createFile and DirectoryEntry.createDirectory methods.
    • The EventSource constructor, Notification constructor, and MutationObserver.observer have different signatures -- in all of these cases the Map argument now uses optional named parameters instead.
    • Window.requestFileSystem and WorkerContext.requestFileSystem have a slightly different signature. By default the user only needs to specify the desired file system size, and we will request temporary storage. The user can specify that they want permanent storage by setting a named optional parameter to true.
  • dart:io
    • The event stream from a WebSocket is now a stream of the messages (of type List<int> or type String). The close event is now the onDone on the stream with the close code and close reason available as properties on the WebSocket object.
    • The IOSink interface now implements StringSink. This renames addString to write, add to writeBytes and addStream to writeStream.
  • pub
    • Support for SDK packages (depending on a package directly from the locally-installed SDK) has been removed. All SDK packages are and have been available from pub.dartlang.org for months and almost all users should have moved over at this point so it shouldn’t affect many.

And as always,view the changelog for the full list of changes, and to get started with the Editor see our tutorial.

Popular posts from this blog

Dart in 2016: The fastest growing programming language at Google, 2nd fastest growing in TIOBE Index

Dart was the fastest growing programming language at Google in 2016 with millions of lines of code written. It also made it to TIOBE Index Top 20 this month (see TIOBE's methodology).

It takes time to build something as ambitious as Dart and, in some ways, Dart is still in its infancy. But we're glad the hard work is starting to pay off.

Many thanks to our amazing community!

We're going to celebrate by ... releasing 1.22 next week (as per our usual 6 week release schedule).

The new Google AdSense user interface: built with AngularDart

AdSense is a free, simple way to earn money by placing ads on your website. The team just launched a completely new version of their app for publishers. Read all about it here. We asked Daniel White, the tech lead for the project, some questions because the new UI happens to be built with Dart and Angular2.


AdSense launched way back in 2003. How long is it since the last big redesign?
Last big redesign was called ‘AdSense 3’ and launched about 6 years ago. It was written in Google Web Toolkit (GWT) and the UI has evolved through several iterations - but this is the first ground-up redesign in 6 years. There are a number of long-standing UX issues that we’ve taken the opportunity to solve. A big shout-out to our UX team who’ve been 100% behind this project. We couldn’t have done it without them!

How many software engineers worked on the project?
Purely on the AdSense applications, we have a team of close to 100. Around 25% of them write Dart.

How many lines of code?
We have around 160K LO…

A stronger Dart for everyone

We are constantly asking ourselves:
How do we make developers even more productive when writing Dart apps? We believe that a critical part of the answer to this question is to make strongmode – a sound static type system for Dart – the standard for all Dart developers.

Teams that use Dart to build apps like Soundtrap, AdWords, AdSense, and Greentea say they really enjoy using strong mode features, such as early error detection. In fact, teams that have switched completely to strong mode cite not only early error detection but also better code readability and maintainability as major benefits. We hear this both from small teams and Рeven more so Рfrom large teams with hundreds of developers writing and maintaining millions of lines of Dart code. As Björn Sperber from Soundtrap says,
Strong mode and the smooth integration with IntelliJ is a joy to use and a huge improvement. If you’ve tried out Flutter, you’ve already used strong mode checks from the Dart analyzer.

Given the benefits …