Today (May 8, 2019) we announce the release of the Dart 2.3 SDK with new language constructs that improve your development experience in creating user interfaces, new support for the Flutter UI development tools and two new websites: dart.dev and pub.dev .
Every year, we look forward to a survey of developers StackOverflow Developer Survey , which provides a complete set of data on trends in development and the attitudes of 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 in the list of the most 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 all the 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.
Speaking about the development of "clients", it is important to say that one of the long-standing joint 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 abstractions of a general-purpose programming language when creating a user interface.
Over the last few releases, we have made several improvements, such as simplifying the code for creating widgets , adding an automatic int-to-double conversion, 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 widget node tree. 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 a spread operator to ""
elements of one list into another. In the following example, buildMainElements()
returns a list of widgets, which is then decompressed 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 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 of Flutter 1.5 and are available in the release of Dart 2.3 , which you can already download. We also added new rules that can be configured in the analyzer so that the use of the new spread , collection if and collection for features is recommended.
For more information on all the work that was done to add these features, check out a recent article from Bob Nystrom (aka munificentbob ), 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.
In addition to the development improvements on Dart, we also expanded support for the IDE by adding new UI Guides
functionality. UI Guides
are horizontal and vertical lines displayed in 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 the UI Guides
show that the user interface is built from Expanded Column
, containing several KeyRows
, each of which contains a NumberKeys
.
UI Guides
are available in version 35.2 of the plugin for IntelliJ IDEA and Android Studio. To enable, select Preferences > Languages & Frameworks > Flutter > 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 automatic import feature is available in VS Code in the Dart plugin from version 2.26 , in IntelliJ 2019.1 and the upcoming release of Android Studio 3.5.
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 carried out a huge reorganization of all content in order to simplify its search, and added new pages for the main content that was missing before.
In a similar way, we visually updated the Pub package site and moved it to a new convenient URL: pub.dev
We'd love to hear your feedback on both sites. If you find a problem or have a suggestion, please create an issue
in the dart.dev issue or pub.dev issue tracker. Thanks for your support!
Source: https://habr.com/ru/post/451318/
All Articles