By Michael Thomsen, Dart Product Manager
Dart 2.16 is released
Dart 2.16 was released last week. Although no new language features have been added, this release includes several fixes (including security vulnerabilities), the ability to specify supported platforms when releasing the Dart package, and a new search interface has been updated to the pub.dev website.
Dart 2.16, released with Flutter 2.10, is still migrating the old command line tool to the new Dart command line tool. Dart Doc and Dart Analyzer have been deprecated in this release. Dart Doc and Dart Analyze correspond to the new commands, respectively. The dartDoc, DartAnalyzer, and pub commands are scheduled to be completely removed in Dart 2.17.
The history command | Alternate DART command | Deprecated version | Stop using 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 of the Dart SDK repository for more instructions on all of the planned deprecations.
Dart 2.16 also includes a fix for a security vulnerability and two damaging changes:
dart:io
The HttpClient API in can now be setauthroization
,www-authenticate
,cookie
andcookie2
These request headers. Prior to Dart 2.16, the implementation of the redirection logic in the SDK had a bug where these request headers (which may contain sensitive information) were sent when cross-domain redirection occurred. In Dart 2.16, these request headers have been removed and you can read themCVE – 2022-0451For more details.dart:io
In theDirectory.rename
The API adjusts the behavior on the Windows platform: directories with the same target name will not be removed (issue)# 47653).- Left over from Dart 1.x
Platform.packageRoot
和Isolate.packageRoot
It has been removed# 47769), they do not work in Dart 2.x.
To learn more about the changes to Dart 2.16, check out the update log.
Declare the platforms supported by 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 may have a package that relies on apis on a particular operating system, or it uses libraries like Dart: FFI that are only available on native platforms but not on Web platforms, etc.
In Dart version 2.16, you can manually declare the platforms supported by the package in PubSpec. For example, if your package only supports Windows and macOS, you can declare it in pubspec.yaml like this:
Name: mypackage version: 1.0.0 platforms: Windows: macos: Dependencies:Copy the code
If you are developing a Dart package that supports a different platform than pub.dev automatically identifies, you can declare this manually in the new Platforms TAB. If you are developing and sharing a Flutter plugin that contains platform-specific code (for example, Kotlin or Swift), the Flutter Plugin tag can specify the supported platforms.
Pub.dev new search experience
In response to requests from developers, we have provided better support for searches on pub.dev. The main purpose of this change is to help you differentiate and search supported platforms. Here’s a preview of the new search interface:
The new search screen has a search filter bar on the left that you can use to limit your search:
- Platforms: Select one or more Platforms, search results will only contain packages that support the selected platform;
- SDKs: Select Dart or Flutter to limit the result to packages that support Dart SDK or Flutter SDK;
- Advanced: Additional search options, such as filter out packages marked Flutter Favorite.
Air safety progress
Since we officially released robust air safety in Dart 2.12 a year ago, the speed with which the community and the Dart ecosystem have migrated to air safety has been impressive: As of last week, the top 250 packages have 100% support for air security, and the top 1000 Pacakge have 96% support for air security! Thank you to all package authors who contributed to air safety!
The migration schedule for applications to air security is also optimistic, meaning that applications and all their dependencies support air security. According to our statistics, 71% of the Flutter tool is now running in sound air safe mode. If you haven’t started yet, you are ready to start now!
Upcoming content
We hope you find the search interface updates to pub.dev helpful, and we welcome feedback at any time. We plan to release the next Dart SDK in the second quarter of 2022, and we’re still working on some exciting language features that we hope to release later this year.
Thank you
- Improved Tooling and Platform Handling
- Link: medium.com/dartlang/da…
- CFUG team Alex, Jia Kang, Fan Deer
- Drawing: Lynn