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 command | Alternative dart commands | Deprecated version | Deactivated version |
---|---|---|---|
stagehand | dart create | 2.14 | 2.14 |
dartfmt | dart format | 2.14 | 2.15 |
dart2native | dart compile exe | 2.14 | 2.15 |
dart2js | dart compile js | 2.17 | 2.18 |
dartdevc | none | 2.17 | 2.18 |
dartanalyzer | dart analyze | 2.16 | 2.17 |
package:analyzer_cli | dart analyze | 2.16 | 2.17 |
dartdoc | dart doc | 2.16 | 2.17 |
pub | dart pub | 2.15 | 2.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:
- The HttpClient API in
dart:io
can now set request headersauthroization
,www-authenticate
,cookie
andcookie2
. Prior to Dart 2.16, there was a bug in the implementation of redirection logic in the SDK. When a cross-origin redirection occurred, these request headers (which may contain sensitive information) were sent. In Dart 2.16, these request headers have been removed, you Read CVE-2022–0451 for more details. dart:io
API inDirectory.rename
Adjusted behavior on Windows platforms: directories with the same target name are not deleted (issue #47653 ).Platform.packageRoot
andIsolate.packageRoot
left over in Dart 1.x have been removed (issue #47769 ), they do not work in Dart 2.x.
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:
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
- Original: Dart 2.16: Improved tooling and platform handling
- Links: https://medium.com/dartlang/dart-2-16-improved-tooling-and-platform-handling-dd87abd6bad1
- Translator/Reviewer: CFUG Team Alex, Jia Kang, Milu
- Graphics: Lynn
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。