[Translation] Announced Dart 2.3: optimized for developing user interfaces

[Translation] Announced Dart 2.3: optimized for developing user interfaces


Today (May 8, 2019) we announce the release of the Dart 2.3 SDK with new language constructs that improve your development experience when creating user interfaces, new support tools for developing Flutter UI and two new websites: dart.dev and pub.dev .


acceleration impulse


Every year we look forward to a survey of StackOverflow Developer Survey , which provides a complete set of data on trends in development and moods developers in relation to various technologies. This year, data showed an increase in popularity and awareness of Dart, which first entered the list of favorite languages ​​and ranked next to other popular languages, such as JavaScript, C # and Go, and ahead of such as C ++, F # and R. At the same time, our good friends in the Flutter community ranked third on the list favorite frameworks . On Codementor last month, a survey on what programming languages ​​should and should not be taught, also reported good news:


"The two programming languages ​​that really deserve the title of" Most Improved "are Dart and Ruby." Codementor, April 2019 [source]

We would like to thank you very much all developers in the dart community. It is very important for us to see how you take Dart, give feedback and continue to be with us when we try to create the best client-optimized language for fast applications that run on any platform.


New language features for developing user interfaces


Speaking about the development of "clients", it is important to say that one of the long-standing collaborative projects of the Dart and Flutter teams provides excellent opportunities for creating a user interface using Dart without the need for a markup language. We believe that the use of one language for behavior and representation has sufficient advantages. These include the reduction of context switches, the absence of the need to learn two languages ​​and providing the use of all the properties of general-purpose programming language abstractions when creating a user interface.


Over the past few releases, we have made several improvements, such as simplifying the code for creating widgets , adding an automatic conversion int-to-double and adding Set Literals . In Dart 2.3, we take another big step forward with three new designs for creating user interfaces related to lists, conditions and repetitions in lists.


UI can be viewed as a tree of widget nodes. Some nodes contain lists of widgets, for example, a list of scrollable items. Often these lists are compiled from other lists. To do this, we added spread operator for "unpacking" elements of one list in another.In the following example, buildMainElements () returns a list of widgets, which is then unpacked into an external list using the spread ... operator:


  Widget build (BuildContext context) {
  Return Column (children: [
  Header ()
  ... buildMainElements (),
  Footer ()
  ]);
 }  

Another common user interface task is to enable a specific element based on a condition. For example, you can turn on the Next button on all pages except the last. With Dart 2.3, you can do this using collection if :


  Widget build (BuildContext context) {
  Return Column (children: [
  Text (mainText),
  if (page! = pages.last)
  FlatButton (child: Text ('Next')),
  ]);
 }  

Finally, it is often necessary to build a list of duplicate items. You can make such a list using the collection for :


  Widget build (BuildContext context) {
  Return Column (children: [
  Text (mainText),
  for (var section in sections)
  HeadingAction (section.heading),
  ]);
 }  

Since these three new language features, rather than markup, they can be used in any context where you work with collections. These designs are included in the release Flutter 1.5 and are available in the release Dart 2.3 , which you can already download. We also added new rules that can be set up in the analyzer to apply the new features spread , collection if and was recommended. <. p>

For more information on all the work that was done to add these features, please read with a recent article by Bob Nystrom (aka munificentbo ), an engineer on the Dart team.


We would also like to express our gratitude to the developers who participated in the UX research, which was important for the formation of these new language constructs.


IDE and Editors Features


In addition to the Dart development improvements, we also expanded support for the IDE by adding new UI Guides functionality. The UI Guides are horizontal and vertical lines displayed in the user interface code, which makes it easy to view the tree structure of the build () method in Flutter. Below is an example (from the Calculator application), where UI Guides shows that the user interface is built from Expanded Column containing several KeyRows , each of which contains NumberKeys .



UI Guides are available in version 35.2 of the plug-in for IntelliJ IDEA and Android Studio. To enable, select Preferences & gt; Languages ​​& amp; Frameworks & gt; Flutter & gt; UI Guides . We hope to add similar support in VS Code in later releases.


Finally, we noticed that developers often use code completion in their IDEs to learn the API.Completing the code worked well for exploring APIs in libraries that you already imported, but it was not available for APIs in libraries that were not yet imported. Our tools can now support the latest use case: you can call the completion of the code for any prefix, and you will see the completion for all APIs in the current package, the packages on which it directly depends, and the SDK. If you choose completion from a library that has not yet been imported (labeled Auto import , as shown in the following animation), the tool will add an import statement for you.



This auto import feature is available in VS Code in the Dart plugin from version 2.26 , in IntelliJ 2019.1 and the upcoming Android release Studio 3.5.


New Dart and Pub sites


Last but not least, for the past few months we have been very busy creating a new website for the Dart platform: dart.dev



The site has a completely updated main page, focused on explaining the main advantages of the Dart platform. We also updated the documentation pages to have better navigation and greater visual appeal. Finally, we conducted a huge reorganization of all content to simplify its search, and added new pages for the main content that was missing before.


In the same way, we visually updated the website of the Pub packages and moved it to a new convenient URL: pub.dev


We'd love to hear your feedback from both sites. If you find a problem or have a suggestion, please create a issue in dart.dev issue or pub.dev issue tracker. Thank you for your support!

Source text: [Translation] Announced Dart 2.3: optimized for developing user interfaces