Text / Michael Thomsen, Dart Product Manager

Dart 2.16 officially released

The official version of Dart 2.16 was released last week. Although no new language features have been added, this release includes several bug fixes (including fixes for security vulnerabilities), supported platforms can also be specified when the Dart package is released, and the pub.dev website has also been updated with a new search interface.

Dart 2.16, released with Flutter 2.10 , is still migrating the old command line tools to the new dart command line tools. In this version, dartdoc and dartanalyzer have been deprecated, and the corresponding new commands are dart doc and dart analyze . The three commands dartdoc , dartanalyzer and pub are planned to be completely removed in Dart 2.17.

history commandAlternative dart commandsDeprecated versionDeactivated version
stagehanddart create2.142.14
dartfmtdart format2.142.15
dart2nativedart compile exe2.142.15
dart2jsdart compile js2.172.18
dartdevcnone2.172.18
dartanalyzerdart analyze2.162.17
package:analyzer_clidart analyze2.162.17
dartdocdart doc2.162.17
pubdart pub2.152.17

See Issue #46100 in the Dart SDK repository for more descriptions of all planned deprecated commands.

Dart 2.16 also includes a fix for a security bug, as well as two breaking changes:

To learn more about the changes in Dart 2.16, check out the changelog .

Declares the supported platforms of the package on pub.dev

Dart is designed with portability in mind, so we try to make the code run on as many platforms as possible. However, developers may occasionally create or share packages on pub.dev that are designed for only one or a few platforms. You might have a package that depends on an API on a specific OS, or it uses a library like dart:ffi is only available on the native platform but not the web platform, etc.

In Dart 2.16, you can manually declare the platforms supported by the package in the pubspec. For example, if your package only supports Windows and macOS, you can declare this in pubspec.yaml :

name: mypackage  
version: 1.0.0

platforms:  
  windows:  
  macos:

dependencies:

When you are developing a Dart package that supports a different platform than what pub.dev automatically recognizes, you can manually declare it at the new platforms tag. If you are developing and sharing a Flutter plugin that contains code for a specific platform (for example, Kotlin or Swift), the Flutter plugin tag can specify the supported platforms.

pub.dev new search experience

In response to developer requests, we have improved support for searching on pub.dev. The main purpose of this change is to help you differentiate and search for supported platforms. Here's a preview of the new search interface:

Pub.dev 的搜索界面,侧边栏包含 Platforms、SDKs 和高级选项

The new search interface has a search filter bar on the left, which you can use to limit your search:

  • Platforms : Select one or more platforms, and the search results will only include packages that support the selected platform;
  • SDKs : Select Dart or Flutter to limit the results to packages that support Dart SDK or Flutter SDK;
  • Advanced (advanced options) : Additional search options, such as filtering for packages marked as Flutter Favorite.

Air Safety Progress

Since we officially released robust null security in Dart 2.12 a year ago, the speed at which the community and Dart ecosystem have migrated to null security has been astounding: as of last week, 100% of the top 250 packages have supported null security. Safety, 96% of the top 1000 pacakge supports empty safety! Thank you to all package authors who contributed to null safety!

The migration progress of application migration to null safety is also very optimistic, which means that the application and all its dependencies support null safety. According to our statistics, 71% of Flutter tools are running in a sane empty safe mode, if you haven't started, you can do it now!

upcoming content

We hope the pub.dev search interface update is helpful, and feel free to for feedback . We plan to release the next Dart SDK release in the second quarter of 2022, and we are also following up on some exciting language features , which we hope to later this year.

Thanks


Flutter
350 声望2.5k 粉丝

Flutter 为应用开发带来了革新: 只要一套代码库,即可构建、测试和发布适用于移动、Web、桌面和嵌入式平台的精美应用。Flutter 中文开发者网站 flutter.cn