
Dart 2.3 announced: optimized for user interface development
- Transfer
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 for Flutter UI development tools, and two new websites: dart.dev and pub.dev .
Acceleration momentum
Each year, we look forward to a StackOverflow Developer Survey of developers , which provides a complete set of data on development trends and the mood of developers regarding various technologies. This year, the data showed an increase in popularity and awareness of Dart, which first entered the list of favorite languages and took a place alongside other popular languages such as JavaScript, C # and Go and ahead of such as C ++, F # and R. At the same time At present, our good friends in the community Flutter
took third place in the list of our favorite frameworks . Last month, at Codementor, a survey on which programming languages should and should not be taught also reported good news:
"The two programming languages that truly earned the title of" Most Advanced "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 accept Dart, give feedback and continue to be with us when we try to create the best client-optimized language for fast applications that work on any platform.
New language features for user interface development
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 using one language for behavior and presentation has enough advantages. These include reducing context switches, no need to learn two languages, and providing the use of all the abstractions of a general-purpose programming language when creating a user interface.
Over the past few releases, we have made several improvements, such as simplifying the code for creating widgets , adding automatic int-to-double conversion, and adding Set literals . In Dart 2.3, we take another big step forward with three new designs to create a user interface for lists, conditions, and repetitions in lists.
UI can be considered 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 a spread operator for "распаковки"
elements of one list to another. 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 include a specific item based on a condition. For example, you can enable 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 elements. 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 are three new features of the language, not markup, they can be used in any context where you work with collections. These designs are included in the Flutter 1.5 release and are available in the Dart 2.3 release , which you can already download. We also added new rules that you can configure 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 has been done to add these features, check out a recent article by Bob Nystrom (aka munificentbob ), an engineer on the Dart team.
We would also like to express our gratitude to the developers who participated in UX research, which were important for the formation of these new language constructs.
IDE and editors features
In addition to the development improvements on Dart, we have also expanded support for the IDE by adding new functionality UI Guides
. UI Guides
are horizontal and vertical lines displayed in the user interface code, which simplifies viewing the tree structure of the method build ()
in Flutter. Below is an example (from the Calculator application), where they UI Guides
show that the user interface is built from Expanded Column
containing several KeyRows
, each of which contains NumberKeys
.
UI Guides
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 to VS Code in later releases.
Finally, we noticed that developers often use code completion in their IDEs to learn the APIs. Code completion worked well for learning APIs in libraries that you already imported, but it was not available for APIs in libraries that haven't been imported yet. Our tools can now support the last use case: you can cause code completion for any prefix, and you will see terminations for all APIs in the current package, packages on which it directly depends, and the SDK. If you select the termination from a library that has not yet been imported (marked 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.
New Dart and Pub Sites
Last, but not least, the last few months we have been very busy creating a new website for the Dart platform: dart.dev
The site has a completely updated home page, focused on explaining the main advantages of the Dart platform. We have also updated the documentation pages to have better navigation and greater visual appeal. Finally, we made a huge reorganization of all the content to make it easier to find, and added new pages for the main content that was missing before.
Similarly, we visually updated the Pub packages site and moved it to a new convenient URL: pub.dev
We look forward to hearing your feedback on both sites. If you find a problem or have a suggestion, please create issue
a tracker in the dart.dev issue or pub.dev issue . Thanks for your support!