Skip to main content

New site for Dart news and articles

For the latest Dart news, visit our new blog at  https://medium.com/dartlang .

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.