| ## 3.6.0 |
| |
| ### Language |
| |
| - **Breaking Change** [#56065][]: The context used by the compiler and analyzer |
| to perform type inference on the operand of a `throw` expression has been |
| changed from the "unknown type" to `Object`. This makes the type system more |
| self-consistent, because it reflects the fact that it's not legal to throw |
| `null`. This change is not expected to make any difference in practice. |
| |
| [#56065]: https://github.com/dart-lang/sdk/issues/56065 |
| |
| ### Libraries |
| |
| #### `dart:js_interop` |
| |
| - Added constructors for `JSArrayBuffer`, `JSDataView`, and concrete typed array |
| types e.g. `JSInt8Array`. |
| - Added `length` and `[]`/`[]=` operators to `JSArray`. |
| - Added `toJSCaptureThis` so `this` is passed in from JavaScript to the |
| callback as the first parameter. |
| |
| ## 3.5.0 |
| |
| ### Language |
| |
| - **Breaking Change** [#55418][]: The context used by the compiler to perform |
| type inference on the operand of an `await` expression has been changed to |
| match the behavior of the analyzer. This change is not expected to make any |
| difference in practice. |
| |
| - **Breaking Change** [#55436][]: The context used by the compiler to perform |
| type inference on the right hand side of an "if-null" expression (`e1 ?? e2`) |
| has been changed to match the behavior of the analyzer. change is expected to |
| have low impact on real-world code. But in principle it could cause |
| compile-time errors or changes in runtime behavior by changing inferred |
| types. The old behavior can be restored by supplying explicit types. |
| |
| [#55418]: https://github.com/dart-lang/sdk/issues/55418 |
| [#55436]: https://github.com/dart-lang/sdk/issues/55436 |
| |
| ### Libraries |
| |
| #### `dart:core` |
| |
| - **Breaking Change** [#44876][]: `DateTime` on the web platform now stores |
| microseconds. The web implementation is now practically compatible with the |
| native implementation, where it is possible to round-trip a timestamp in |
| microseconds through a `DateTime` value without rounding the lower |
| digits. This change might be breaking for apps that rely in some way on the |
| `.microsecond` component always being zero, for example, expecting only three |
| fractional second digits in the `toString()` representation. Small |
| discrepancies in arithmetic due to rounding of web integers may still occur |
| for extreme values, (1) `microsecondsSinceEpoch` outside the safe range, |
| corresponding to dates with a year outside of 1685..2255, and (2) arithmetic |
| (`add`, `subtract`, `difference`) where the `Duration` argument or result |
| exceeds 570 years. |
| |
| [#44876]: https://github.com/dart-lang/sdk/issues/44876 |
| |
| #### `dart:io` |
| |
| - **Breaking Change** [#55786][]: `SecurityContext` is now `final`. This means |
| that `SecurityContext` can no longer be subclassed. `SecurityContext` |
| subclasses were never able to interoperate with other parts of `dart:io`. |
| |
| - A `ConnectionTask` can now be created using an existing `Future<Socket>`. |
| Fixes [#55562]. |
| |
| [#55786]: https://github.com/dart-lang/sdk/issues/55786 |
| [#55562]: https://github.com/dart-lang/sdk/issues/55562 |
| |
| #### `dart:typed_data` |
| |
| - **Breaking Change** [#53785][]: The unmodifiable view classes for typed data |
| have been removed. These classes were deprecated in Dart 3.4. |
| |
| To create an unmodifiable view of a typed-data object, use the |
| `asUnmodifiableView()` methods added in Dart 3.3. |
| |
| - Added superinterface `TypedDataList` to typed data lists, implementing both |
| `List` and `TypedData`. Allows abstracting over all such lists without losing |
| access to either the `List` or the `TypedData` members. |
| A `ByteData` is still only a `TypedData`, not a list. |
| |
| [#53785]: https://github.com/dart-lang/sdk/issues/53785 |
| |
| #### `dart:js_interop` |
| |
| - **Breaking Change** [#55508][]: `importModule` now accepts a `JSAny` instead |
| of a `String` to support other JS values as well, like `TrustedScriptURL`s. |
| |
| - **Breaking Change** [#55267][]: `isTruthy` and `not` now return `JSBoolean` |
| instead of `bool` to be consistent with the other operators. |
| |
| - **Breaking Change** `ExternalDartReference` no longer implements `Object`. |
| `ExternalDartReference` now accepts a type parameter `T` with a bound of |
| `Object?` to capture the type of the Dart object that is externalized. |
| `ExternalDartReferenceToObject.toDartObject` now returns a `T`. |
| `ExternalDartReferenceToObject` and `ObjectToExternalDartReference` are now |
| extensions on `T` and `ExternalDartReference<T>`, respectively, where `T |
| extends Object?`. See [#55342][] and [#55536][] for more details. |
| |
| - Fixed some consistency issues with `Function.toJS` across all compilers. |
| Specifically, calling `Function.toJS` on the same function gives you a new JS |
| function (see issue [#55515][]), the maximum number of arguments that are |
| passed to the JS function is determined by the static type of the Dart |
| function, and extra arguments are dropped when passed to the JS function in |
| all compilers (see [#48186][]). |
| |
| [#55508]: https://github.com/dart-lang/sdk/issues/55508 |
| [#55267]: https://github.com/dart-lang/sdk/issues/55267 |
| [#55342]: https://github.com/dart-lang/sdk/issues/55342 |
| [#55536]: https://github.com/dart-lang/sdk/issues/55536 |
| [#55515]: https://github.com/dart-lang/sdk/issues/55515 |
| [#48186]: https://github.com/dart-lang/sdk/issues/48186 |
| |
| ### Tools |
| |
| #### Linter |
| |
| - Added the [`unintended_html_in_doc_comment`][] lint. |
| - Added the [`invalid_runtime_check_with_js_interop_types`][] lint. |
| - Added the [`document_ignores`][] lint. |
| |
| [`unintended_html_in_doc_comment`]: https://dart.dev/lints/unintended_html_in_doc_comment |
| [`invalid_runtime_check_with_js_interop_types`]: https://dart.dev/lints/invalid_runtime_check_with_js_interop_types |
| [`document_ignores`]: https://dart.dev/lints/document_ignores |
| |
| #### Pub |
| |
| - New flag `dart pub downgrade --tighten` to restrict lower bounds of |
| dependencies' constraints to the minimum that can be resolved. |
| |
| ### Dart Runtime |
| |
| - The Dart VM only executes sound null safe code, running of unsound null |
| safe code using the option `--no-sound-null-safety` has been removed. |
| |
| - `Dart_NewListOf` and `Dart_IsLegacyType` functions are |
| removed from Dart C API. |
| |
| - `Dart_DefaultCanonicalizeUrl` is removed from the Dart C API. |
| |
| ## 3.4.0 |
| |
| ### Language |
| |
| Dart 3.4 makes improvements to the type analysis of conditional expressions |
| (`e1 ? e2 : e3`), if-null expressions (`e1 ?? e2`), if-null assignments |
| (`e1 ??= e2`), and switch expressions (`switch (e) { p1 => e1, ... }`). To take |
| advantage of these improvements, set your package's |
| [SDK constraint][language version] lower bound to 3.4 or greater |
| (`sdk: '^3.4.0'`). |
| |
| [language version]: https://dart.dev/guides/language/evolution |
| |
| - **Breaking Change** [#54640][]: The pattern context type schema for |
| cast patterns has been changed from `Object?` to `_` (the unknown |
| type), to align with the specification. This change is not expected |
| to make any difference in practice. |
| |
| - **Breaking Change** [#54828][]: The type schema used by the compiler front end |
| to perform type inference on the operand of a null-aware spread operator |
| (`...?`) in map and set literals has been made nullable, to match what |
| currently happens in list literals. This makes the compiler front end behavior |
| consistent with that of the analyzer. This change is expected to be very low |
| impact. |
| |
| [#54640]: https://github.com/dart-lang/sdk/issues/54640 |
| [#54828]: https://github.com/dart-lang/sdk/issues/54828 |
| |
| ### Libraries |
| |
| #### `dart:async` |
| |
| - Added option for `ParallelWaitError` to get some meta-information that |
| it can expose in its `toString`, and the `Iterable<Future>.wait` and |
| `(Future,...,Future).wait` extension methods now provide that information. |
| Should make a `ParallelWaitError` easier to log. |
| |
| #### `dart:cli` |
| |
| - **Breaking change** [#52121][]: `waitFor` is removed in 3.4. |
| |
| #### `dart:ffi` |
| |
| - Added `Struct.create` and `Union.create` to create struct and union views |
| of the sequence of bytes stored in a subtype of `TypedData`. |
| |
| #### `dart:io` |
| |
| - **Breaking change** [#53863][]: `Stdout` has a new field `lineTerminator`, |
| which allows developers to control the line ending used by `stdout` and |
| `stderr`. Classes that `implement Stdout` must define the `lineTerminator` |
| field. The default semantics of `stdout` and `stderr` are not changed. |
| |
| - Deprecates `FileSystemDeleteEvent.isDirectory`, which always returns |
| `false`. |
| |
| [#53863]: https://github.com/dart-lang/sdk/issues/53863 |
| |
| #### `dart:js_interop` |
| |
| - Fixes an issue with several comparison operators in `JSAnyOperatorExtension` |
| that were declared to return `JSBoolean` but really returned `bool`. This led |
| to runtime errors when trying to use the return values. The implementation now |
| returns a `JSBoolean` to align with the interface. See issue [#55024] for |
| more details. |
| |
| - Added `ExternalDartReference` and related conversion functions |
| `toExternalReference` and `toDartObject`. This is a faster alternative to |
| `JSBoxedDartObject`, but with fewer safety guarantees and fewer |
| interoperability capabilities. See [#55187] for more details. |
| |
| - On dart2wasm, `JSBoxedDartObject` now is an actual JS object that wraps the |
| opaque Dart value instead of only externalizing the value. Like the JS |
| backends, you'll now get a more useful error when trying to use it in another |
| Dart runtime. |
| |
| - Added `isA` helper to make type checks easier with interop types. See |
| [#54138][] for more details. |
| |
| [#54138]: https://github.com/dart-lang/sdk/issues/54138 |
| [#55024]: https://github.com/dart-lang/sdk/issues/55024 |
| [#55187]: https://github.com/dart-lang/sdk/issues/55187 |
| |
| #### `dart:typed_data` |
| |
| - **BREAKING CHANGE** [#53218][] [#53785][]: The unmodifiable view classes for |
| typed data are deprecated. |
| |
| To create an unmodifiable view of a typed-data object, use the |
| `asUnmodifiableView()` methods added in Dart 3.3: |
| |
| ```dart |
| Uint8List data = ...; |
| final readOnlyView = data.asUnmodifiableView(); |
| // readOnlyView has type Uint8List, and throws if attempted modified. |
| ``` |
| |
| The reason for this change is to allow more flexibility in the implementation |
| of typed data, so the native and web platforms can use different strategies |
| to ensure that typed data has good performance. |
| |
| The deprecated types will be removed in Dart 3.5. |
| |
| [#53218]: https://github.com/dart-lang/sdk/issues/53218 |
| [#53785]: https://github.com/dart-lang/sdk/issues/53785 |
| |
| ### Tools |
| |
| #### Analyzer |
| |
| - Improved code completion. Fixed over 50% of completion correctness bugs, |
| tagged `analyzer-completion-correctness` in the [issue |
| tracker][analyzer-completion-correction-issues]. |
| |
| - Support for new annotations introduced in version 1.14.0 of the [meta] |
| package. |
| |
| - Support for the [`@doNotSubmit`] annotation, noting that any usage of an |
| annotated member should not be submitted to source control. |
| |
| - Support for the [`@mustBeConst`] annotation, which indicates that an |
| annotated parameter only accepts constant arguments. |
| |
| [analyzer-completion-correction-issues]: https://github.com/dart-lang/sdk/labels/analyzer-completion-correctness |
| [meta]: https://pub.dev/packages/meta |
| [`@doNotSubmit`]: https://pub.dev/documentation/meta/latest/meta/doNotSubmit-constant.html |
| [`@mustBeConst`]: https://pub.dev/documentation/meta/latest/meta/mustBeConst-constant.html |
| |
| #### Linter |
| |
| - Added the [`unnecessary_library_name`][] lint. |
| - Added the [`missing_code_block_language_in_doc_comment`][] lint. |
| |
| [`unnecessary_library_name`]: https://dart.dev/lints/unnecessary_library_name |
| [`missing_code_block_language_in_doc_comment`]: https://dart.dev/lints/missing_code_block_language_in_doc_comment |
| |
| #### Compilers |
| |
| - The compilation environment will no longer pretend to contain entries with |
| value `""` for all `dart.library.foo` strings, where `dart:foo` is not an |
| available library. Instead there will only be entries for the available |
| libraries, like `dart.library.core`, where the value was, and still is, |
| `"true"`. This should have no effect on `const bool.fromEnvironment(...)` or |
| `const String.fromEnvironment(...)` without a `defaultValue` argument, an |
| argument which was always ignored previously. It changes the behavior of |
| `const bool.hasEnvironment(...)` on such an input, away from always being |
| `true` and therefore useless. |
| |
| #### DevTools |
| |
| - Updated DevTools to version 2.33.0 from 2.31.1. |
| To learn more, check out the release notes for versions |
| [2.32.0][devtools-2-32-0] and [2.33.0][devtools-2-33-0]. |
| |
| [devtools-2-32-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.32.0 |
| [devtools-2-33-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.33.0 |
| |
| #### Pub |
| |
| - Dependency resolution and `dart pub outdated` will now surface if a dependency |
| is affected by a security advisory, unless the advisory is listed under a |
| `ignored_advisories` section in the `pubspec.yaml` file. To learn more about |
| pub's support for security advisories, visit |
| [dart.dev/go/pub-security-advisories][pub-security-advisories]. |
| |
| - `path`-dependencies inside `git`-dependencies are now resolved relative to the |
| git repo. |
| |
| - All `dart pub` commands can now be run from any subdirectory of a project. Pub |
| will find the first parent directory with a `pubspec.yaml` and operate |
| relative it. |
| |
| - New command `dart pub unpack` that downloads a package from pub.dev and |
| extracts it to a subfolder of the current directory. |
| |
| This can be useful for inspecting the code, or playing with examples. |
| |
| [pub-security-advisories]: https://dart.dev/go/pub-security-advisories |
| |
| ### Dart Runtime |
| |
| - Dart VM flags and options can now be provided to any executable generated |
| using `dart compile exe` via the `DART_VM_OPTIONS` environment variable. |
| `DART_VM_OPTIONS` should be set to a list of comma-separated flags and options |
| with no whitespace. Options that allow for multiple values to be provided as |
| comma-separated values are not supported (e.g., |
| `--timeline-streams=Dart,GC,Compiler`). |
| |
| Example of a valid `DART_VM_OPTIONS` environment variable: |
| |
| ```bash |
| DART_VM_OPTIONS=--random_seed=42,--verbose_gc |
| ``` |
| |
| - Dart VM no longer supports external strings: `Dart_IsExternalString`, |
| `Dart_NewExternalLatin1String` and `Dart_NewExternalUTF16String` functions are |
| removed from Dart C API. |
| |
| ## 3.3.4 - 2024-04-17 |
| |
| This is a patch release that: |
| |
| - Fixes an issue with JS interop in dart2wasm where JS interop methods that used |
| the enclosing library's `@JS` annotation were actually using the invocation's |
| enclosing library's `@JS` annotation. (issue [#55430]). |
| |
| [#55430]: https://github.com/dart-lang/sdk/issues/55430 |
| |
| ## 3.3.3 - 2024-03-27 |
| |
| This is a patch release that: |
| |
| - Fixes an issue where dart vm crashed when running on pre-SSE41 older CPUs on Windows (issue [#55211][]). |
| |
| [#55211]: https://github.com/dart-lang/sdk/issues/55211 |
| |
| ## 3.3.2 - 2024-03-20 |
| |
| This is a patch release that: |
| |
| - Fixes an issue in the CFE that placed some structural parameter references out |
| of their context in the code restored from dill files, causing crashes in the |
| incremental compiler whenever it restored a typedef from dill such that the |
| typedef contained a generic function type on its right-hand side (issue |
| [#55158][]). |
| - Fixes an issue in the CFE that prevented redirecting factories from being |
| resolved in initializers of extension types (issue [#55194][]). |
| - Fixes an issues with VM's implementation of `DateTime.timeZoneName` |
| on Windows, which was checking whether current date is in the summer or |
| standard time rather than checking if the given moment is in the summer or |
| standard time (issue [#55240][]). |
| |
| [#55158]: https://github.com/dart-lang/sdk/issues/55158 |
| [#55194]: https://github.com/dart-lang/sdk/issues/55194 |
| [#55240]: https://github.com/dart-lang/sdk/issues/55240 |
| |
| ## 3.3.1 - 2024-03-06 |
| |
| This is a patch release that: |
| |
| - Fixes an issue in dart2js where object literal constructors in interop |
| extension types would fail to compile without an `@JS` annotation on the |
| library (issue [#55057][]). |
| - Disallows certain types involving extension types from being used as the |
| operand of an `await` expression, unless the extension type itself implements |
| `Future` (issue [#55095][]). |
| |
| [#55057]: https://github.com/dart-lang/sdk/issues/55057 |
| [#55095]: https://github.com/dart-lang/sdk/issues/55095 |
| |
| ## 3.3.0 |
| |
| ### Language |
| |
| Dart 3.3 adds [extension types] to the language. To use them, set your |
| package's [SDK constraint][language version] lower bound to 3.3 or greater |
| (`sdk: '^3.3.0'`). |
| |
| #### Extension types |
| |
| [extension types]: https://github.com/dart-lang/language/issues/2727 |
| |
| An _extension type_ wraps an existing type with a different, static-only |
| interface. It works in a way which is in many ways similar to a class that |
| contains a single final instance variable holding the wrapped object, but |
| without the space and time overhead of an actual wrapper object. |
| |
| Extension types are introduced by _extension type declarations_. Each |
| such declaration declares a new named type (not just a new name for the |
| same type). It declares a _representation variable_ whose type is the |
| _representation type_. The effect of using an extension type is that the |
| _representation_ (that is, the value of the representation variable) has |
| the members declared by the extension type rather than the members declared |
| by its "own" type (the representation type). Example: |
| |
| ```dart |
| extension type Meters(int value) { |
| String get label => '${value}m'; |
| Meters operator +(Meters other) => Meters(value + other.value); |
| } |
| |
| void main() { |
| var m = Meters(42); // Has type `Meters`. |
| var m2 = m + m; // OK, type `Meters`. |
| // int i = m; // Compile-time error, wrong type. |
| // m.isEven; // Compile-time error, no such member. |
| assert(identical(m, m.value)); // Succeeds. |
| } |
| ``` |
| |
| The declaration `Meters` is an extension type that has representation type |
| `int`. It introduces an implicit constructor `Meters(int value);` and a |
| getter `int get value`. `m` and `m.value` is the very same object, but `m` |
| has type `Meters` and `m.value` has type `int`. The point is that `m` |
| has the members of `Meters` and `m.value` has the members of `int`. |
| |
| Extension types are entirely static, they do not exist at run time. If `o` |
| is the value of an expression whose static type is an extension type `E` |
| with representation type `R`, then `o` is just a normal object whose |
| run-time type is a subtype of `R`, exactly like the value of an expression |
| of type `R`. Also the run-time value of `E` is `R` (for example, `E == R` |
| is true). In short: At run time, an extension type is erased to the |
| corresponding representation type. |
| |
| A method call on an expression of an extension type is resolved at |
| compile-time, based on the static type of the receiver, similar to how |
| extension method calls work. There is no virtual or dynamic dispatch. This, |
| combined with no memory overhead, means that extension types are zero-cost |
| wrappers around their representation value. |
| |
| While there is thus no performance cost to using extension types, there is |
| a safety cost. Since extension types are erased at compile time, run-time |
| type tests on values that are statically typed as an extension type will |
| check the type of the representation object instead, and if the type check |
| looks like it tests for an extension type, like `is Meters`, it actually |
| checks for the representation type, that is, it works exactly like `is int` |
| at run time. Moreover, as mentioned above, if an extension type is used as |
| a type argument to a generic class or function, the type variable will be |
| bound to the representation type at run time. For example: |
| |
| ```dart |
| void main() { |
| var meters = Meters(3); |
| |
| // At run time, `Meters` is just `int`. |
| print(meters is int); // Prints "true". |
| print(<Meters>[] is List<int>); // Prints "true". |
| |
| // An explicit cast is allowed and succeeds as well: |
| List<Meters> meterList = <int>[1, 2, 3] as List<Meters>; |
| print(meterList[1].label); // Prints "2m". |
| } |
| ``` |
| |
| Extension types are useful when you are willing to sacrifice some run-time |
| encapsulation in order to avoid the overhead of wrapping values in |
| instances of wrapper classes, but still want to provide a different |
| interface than the wrapped object. An example of that is interop, where you |
| may have data that are not Dart objects to begin with (for example, raw |
| JavaScript objects when using JavaScript interop), and you may have large |
| collections of objects where it's not efficient to allocate an extra object |
| for each element. |
| |
| #### Other changes |
| |
| - **Breaking Change** [#54056][]: The rules for private field promotion have |
| been changed so that an abstract getter is considered promotable if there are |
| no conflicting declarations. There are no conflicting declarations if |
| there are no non-final fields, external fields, concrete getters, or |
| `noSuchMethod` forwarding getters with the same name in the same library. |
| This makes the implementation more consistent and allows |
| type promotion in a few rare scenarios where it wasn't previously allowed. |
| It is unlikely, but this change could cause a breakage by changing |
| an inferred type in a way that breaks later code. For example: |
| |
| ```dart |
| class A { |
| int? get _field; |
| } |
| class B extends A { |
| final int? _field; |
| B(this._field); |
| } |
| test(A a) { |
| if (a._field != null) { |
| var x = a._field; // Previously had type `int?`; now has type `int` |
| ... |
| x = null; // Previously allowed; now causes a compile-time error. |
| } |
| } |
| ``` |
| |
| Affected code can be fixed by adding an explicit type annotation. |
| For example, in the above snippet, `var x` can be changed to `int? x`. |
| |
| It's also possible that some continuous integration configurations might fail |
| if they have been configured to treat warnings as errors, because the expanded |
| type promotion could lead to one of the following warnings: |
| |
| - `unnecessary_non_null_assertion` |
| - `unnecessary_cast` |
| - `invalid_null_aware_operator` |
| |
| These warnings can be addressed in the usual way, by removing the unnecessary |
| operation in the first two cases, or changing `?.` to `.` in the third case. |
| |
| To learn more about other rules surrounding type promotion, |
| check out the guide on [Fixing type promotion failures][]. |
| |
| [#54056]: https://github.com/dart-lang/sdk/issues/54056 |
| [Fixing type promotion failures]: https://dart.dev/tools/non-promotion-reasons |
| |
| ### Libraries |
| |
| #### `dart:core` |
| |
| - `String.fromCharCodes` now allow `start` and `end` to be after the end of |
| the `Iterable` argument, just like `skip` and `take` does on an `Iterable`. |
| |
| #### `dart:ffi` |
| |
| - In addition to functions, `@Native` can now be used on fields. |
| - Allow taking the address of native functions and fields via |
| `Native.addressOf`. |
| - The `elementAt` pointer arithmetic extension methods on |
| core `Pointer` types are now deprecated. |
| Migrate to the new `-` and `+` operators instead. |
| - The experimental and deprecated `@FfiNative` annotation has been removed. |
| Usages should be updated to use the `@Native` annotation. |
| |
| #### `dart:js_interop` |
| |
| - **Breaking Change in the representation of JS types** [#52687][]: JS types |
| like `JSAny` were previously represented using a custom erasure of |
| `@staticInterop` types that were compiler-specific. They are now represented |
| as extension types where their representation types are compiler-specific. |
| This means that user-defined `@staticInterop` types that implemented `JSAny` |
| or `JSObject` can no longer do so and need to use |
| `JSObject.fromInteropObject`. Going forward, it's recommended to use extension |
| types to define interop APIs. Those extension types can still implement JS |
| types. |
| - **JSArray and JSPromise generics**: `JSArray` and `JSPromise` are now generic |
| types whose type parameter is a subtype of `JSAny?`. Conversions to and from |
| these types are changed to account for the type parameters of the Dart or JS |
| type, respectively. |
| - **Breaking Change in names of extensions**: Some `dart:js_interop` extension |
| members are moved to different extensions on the same type or a supertype to |
| better organize the API surface. See `JSAnyUtilityExtension` and |
| `JSAnyOperatorExtension` for the new extensions. This shouldn't make a |
| difference unless the extension names were explicitly used. |
| - Add `importModule` to allow users to dynamically import modules using the JS |
| `import()` expression. |
| |
| [#52687]: https://github.com/dart-lang/sdk/issues/52687 |
| |
| #### `dart:js_interop_unsafe` |
| |
| - Add `has` helper to make `hasProperty` calls more concise. |
| |
| #### `dart:typed_data` |
| |
| - **BREAKING CHANGE** (https://github.com/dart-lang/sdk/issues/53218) The |
| unmodifiable view classes for typed data are deprecated. Instead of using the |
| constructors for these classes to create an unmodifiable view, e.g. |
| |
| ```dart |
| Uint8List data = ... |
| final readOnlyView = UnmodifiableUint8ListView(data); |
| ``` |
| |
| use the new `asUnmodifiableView()` methods: |
| |
| ```dart |
| Uint8List data = ... |
| final readOnlyView = data.asUnmodifiableView(); |
| ``` |
| |
| The reason for this change is to allow more flexibility in the implementation |
| of typed data so the native and web platforms can use different strategies |
| for ensuring typed data has good performance. |
| |
| The deprecated types will be removed in a future Dart version. |
| |
| #### `dart:nativewrappers` |
| |
| - **Breaking Change** [#51896][]: The NativeWrapperClasses are marked `base` so |
| that none of their subtypes can be implemented. Implementing subtypes can lead |
| to crashes when passing such native wrapper to a native call, as it will try |
| to unwrap a native field that doesn't exist. |
| |
| [#51896]: https://github.com/dart-lang/sdk/issues/51896 |
| |
| ### Tools |
| |
| #### Dart command line |
| |
| - The `dart create` command now uses v3 of `package:lints`, |
| including multiple new recommended lints by default. |
| To learn more about the updated collection of lints, |
| check out the `package:lints` [3.0.0 changelog entry][lints-3-0]. |
| |
| [lints-3-0]: https://pub.dev/packages/lints/changelog#300 |
| |
| #### DevTools |
| |
| - Updated DevTools to version 2.31.1 from 2.28.1. |
| To learn more, check out the release notes for versions |
| [2.29.0][devtools-2-29-0], [2.30.0][devtools-2-30-0], |
| and [2.31.0][devtools-2-31-0]. |
| |
| [devtools-2-29-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.29.0 |
| [devtools-2-30-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.30.0 |
| [devtools-2-31-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.31.0 |
| |
| #### Wasm compiler (dart2wasm) |
| |
| - **Breaking Change** [#54004][]: `dart:js_util`, `package:js`, and `dart:js` |
| are now disallowed from being imported when compiling with `dart2wasm`. Prefer |
| using `dart:js_interop` and `dart:js_interop_unsafe`. |
| |
| [#54004]: https://github.com/dart-lang/sdk/issues/54004 |
| |
| #### Development JavaScript compiler (DDC) |
| |
| - Type arguments of `package:js` interop types are now printed as `any` instead |
| of being omitted. This is simply a change to the textual representation of |
| package js types that have type arguments. These type arguments are still |
| completely ignored by the type system at runtime. |
| |
| - Removed "implements <...>" text from the Chrome custom formatter display for |
| Dart classes. This information provides little value and keeping it imposes an |
| unnecessary maintenance cost. |
| |
| #### Production JavaScript compiler (dart2js) |
| |
| - **Breaking Change** [#54201][]: |
| The `Invocation` that is passed to `noSuchMethod` will no longer have a |
| minified `memberName`, even when dart2js is invoked with `--minify`. |
| See [#54201][] for more details. |
| |
| [#54201]: https://github.com/dart-lang/sdk/issues/54201 |
| |
| #### Analyzer |
| |
| - You can now suppress diagnostics in `pubspec.yaml` files by |
| adding an `# ignore: <diagnostic_id>` comment. |
| - Invalid `dart doc` comment directives are now reported. |
| - The [`flutter_style_todos`][] lint now has a quick fix. |
| |
| [`flutter_style_todos`]: https://dart.dev/lints/flutter_style_todos |
| |
| #### Linter |
| |
| - Removed the `iterable_contains_unrelated_type` and |
| `list_remove_unrelated_type` lints. |
| Consider migrating to the expanded |
| [`collection_methods_unrelated_type`][] lint. |
| - Removed various lints that are no longer necessary with sound null safety: |
| - `always_require_non_null_named_parameters` |
| - `avoid_returning_null`, |
| - `avoid_returning_null_for_future` |
| |
| [`collection_methods_unrelated_type`]: https://dart.dev/lints/collection_methods_unrelated_type |
| |
| ## 3.2.3 - 2023-12-06 |
| |
| This is a patch release that: |
| |
| - Disallows final fields to be used in a constant context during analysis |
| (issue [#54232][]). |
| - Upgrades Dart DevTools to version 2.28.4 (issue [#54213][]). |
| - Fixes new AOT snapshots in the SDK failing with SIGILL in ARM |
| environments that don't support the integer division |
| instructions or x86-64 environments that don't support |
| SSE4.1 (issue [#54215][]). |
| |
| [#54232]: https://github.com/dart-lang/sdk/issues/54232 |
| [#54213]: https://github.com/dart-lang/sdk/issues/54213 |
| [#54215]: https://github.com/dart-lang/sdk/issues/54215 |
| |
| ## 3.2.2 - 2023-11-29 |
| |
| This is a patch release that: |
| |
| - Adjusts the nullablity computations in the implementation of the |
| upper bound algorithm in the compiler frontend (issue [#53999][]). |
| |
| - Fixes missing closure code completion entries for function parameters |
| for LSP-based editors like VS Code (issue [#54112][]). |
| |
| [#53999]: https://github.com/dart-lang/sdk/issues/53999 |
| [#54112]: https://github.com/dart-lang/sdk/issues/54112 |
| |
| ## 3.2.1 - 2023-11-22 |
| |
| This is a patch release that: |
| |
| - Fixes the left/mobile sidebar being empty on non-class pages |
| in documentation generated with `dart doc` (issue [#54073][]). |
| |
| - Fixes a JSON array parsing bug that causes a segmentation fault when |
| `flutter test` is invoked with the `--coverage` flag |
| (SDK issue [#54059][], Flutter issue [#124145][]). |
| |
| - Upgrades Dart DevTools to version 2.28.3 (issue [#54085][]). |
| |
| [#54073]: https://github.com/dart-lang/sdk/issues/54073 |
| [#54059]: https://github.com/dart-lang/sdk/issues/54059 |
| [#124145]: https://github.com/flutter/flutter/issues/124145 |
| [#54085]: https://github.com/dart-lang/sdk/issues/54085 |
| |
| ## 3.2.0 - 2023-11-15 |
| |
| ### Language |
| |
| Dart 3.2 adds the following features. To use them, set your package's [SDK |
| constraint][language version] lower bound to 3.2 or greater (`sdk: '^3.2.0'`). |
| |
| [language version]: https://dart.dev/guides/language/evolution |
| |
| - **Private field promotion**: In most circumstances, the types of private final |
| fields can now be promoted by null checks and `is` tests. For example: |
| |
| ```dart |
| class Example { |
| final int? _privateField; |
| Example(this._privateField); |
| |
| f() { |
| if (_privateField != null) { |
| // _privateField has now been promoted; you can use it without |
| // null checking it. |
| int i = _privateField; // OK |
| } |
| } |
| } |
| |
| // Private field promotions also work from outside of the class: |
| f(Example x) { |
| if (x._privateField != null) { |
| int i = x._privateField; // OK |
| } |
| } |
| ``` |
| |
| To ensure soundness, a field is not eligible for field promotion in the |
| following circumstances: |
| - If it's not final (because a non-final field could be changed in between the |
| test and the usage, invalidating the promotion). |
| - If it's overridden elsewhere in the library by a concrete getter or a |
| non-final field (because an access to an overridden field might resolve at |
| runtime to the overriding getter or field). |
| - If it's not private (because a non-private field might be overridden |
| elsewhere in the program). |
| - If it has the same name as a concrete getter or a non-final field in some |
| other unrelated class in the library (because a class elsewhere in the |
| program might extend one of the classes and implement the other, creating an |
| override relationship between them). |
| - If there is a concrete class `C` in the library whose interface contains a |
| getter with the same name, but `C` does not have an implementation of that |
| getter (such unimplemented getters aren't safe for field promotion, because |
| they are implicitly forwarded to `noSuchMethod`, which might not return the |
| same value each time it's called). |
| |
| - **Breaking Change** [#53167][]: Use a more precise split point for refutable |
| patterns. Previously, in an if-case statement, if flow analysis could prove |
| that the scrutinee expression was guaranteed to throw an exception, it would |
| sometimes fail to propagate type promotions implied by the pattern to the |
| (dead) code that follows. This change makes the type promotion behavior of |
| if-case statements consistent regardless of whether the scrutinee expression |
| throws an exception. |
| |
| No live code is affected by this change, but there is a small chance that the |
| change in types will cause a compile-time error to appear in some dead code in |
| the user's project, where no compile-time error appeared previously. |
| |
| [#53167]: https://github.com/dart-lang/sdk/issues/53167 |
| |
| ### Libraries |
| |
| #### `dart:async` |
| |
| - Added `broadcast` parameter to `Stream.empty` constructor. |
| |
| #### `dart:cli` |
| |
| - **Breaking change** [#52121][]: |
| - `waitFor` is disabled by default and slated for removal in 3.4. Attempting |
| to call this function will now throw an exception. Users that still depend |
| on `waitFor` can enable it by passing `--enable_deprecated_wait_for` flag |
| to the VM. |
| |
| [#52121]: https://github.com/dart-lang/sdk/issues/52121 |
| |
| #### `dart:convert` |
| |
| - **Breaking change** [#52801][]: |
| - Changed return types of `utf8.encode()` and `Utf8Codec.encode()` from |
| `List<int>` to `Uint8List`. |
| |
| [#52801]: https://github.com/dart-lang/sdk/issues/52801 |
| |
| #### `dart:developer` |
| |
| - Deprecated the `Service.getIsolateID` method. |
| - Added `getIsolateId` method to `Service`. |
| - Added `getObjectId` method to `Service`. |
| |
| #### `dart:ffi` |
| |
| - Added the `NativeCallable.isolateLocal` constructor. This creates |
| `NativeCallable`s with the same functionality as `Pointer.fromFunction`, |
| except that `NativeCallable` accepts closures. |
| - Added the `NativeCallable.keepIsolateAlive` method, which determines whether |
| the `NativeCallable` keeps the isolate that created it alive. |
| - All `NativeCallable` constructors can now accept closures. Previously |
| `NativeCallable`s had the same restrictions as `Pointer.fromFunction`, and |
| could only create callbacks for static functions. |
| - **Breaking change** [#53311][]: `NativeCallable.nativeFunction` now throws an |
| error if is called after the `NativeCallable` has already been `close`d. Calls |
| to `close` after the first are now ignored. |
| |
| [#53311]: https://github.com/dart-lang/sdk/issues/53311 |
| |
| #### `dart:io` |
| |
| - **Breaking change** [#53005][]: The headers returned by |
| `HttpClientResponse.headers` and `HttpRequest.headers` no longer include |
| trailing whitespace in their values. |
| |
| - **Breaking change** [#53227][]: Folded headers values returned by |
| `HttpClientResponse.headers` and `HttpRequest.headers` now have a space |
| inserted at the fold point. |
| |
| [#53005]: https://dartbug.com/53005 |
| [#53227]: https://dartbug.com/53227 |
| |
| #### `dart:isolate` |
| |
| - Added `Isolate.packageConfigSync` and `Isolate.resolvePackageUriSync` APIs. |
| |
| #### `dart:js_interop` |
| |
| - **Breaking Change on JSNumber.toDart and Object.toJS**: |
| `JSNumber.toDart` is removed in favor of `toDartDouble` and `toDartInt` to |
| make the type explicit. `Object.toJS` is also removed in favor of |
| `Object.toJSBox`. Previously, this function would allow Dart objects to flow |
| into JS unwrapped on the JS backends. Now, there's an explicit wrapper that is |
| added and unwrapped via `JSBoxedDartObject.toDart`. Similarly, |
| `JSExportedDartObject` is renamed to `JSBoxedDartObject` and the extensions |
| `ObjectToJSExportedDartObject` and `JSExportedDartObjectToObject` are renamed |
| to `ObjectToJSBoxedDartObject` and `JSBoxedDartObjectToObject` in order to |
| avoid confusion with `@JSExport`. |
| - **Type parameters in external APIs**: |
| Type parameters must now be bound to a static interop type or one of the |
| `dart:js_interop` types like `JSNumber` when used in an external API. This |
| only affects `dart:js_interop` classes and not `package:js` or other forms of |
| JS interop. |
| - **Subtyping `dart:js_interop` types**: |
| `@staticInterop` types can subtype only `JSObject` and `JSAny` from the set of |
| JS types in `dart:js_interop`. Subtyping other types from `dart:js_interop` |
| would result in confusing type errors before, so this makes it a static error. |
| - **Global context of `dart:js_interop` and `@staticInterop` APIs**: |
| Static interop APIs will now use the same global context as non-static interop |
| instead of `globalThis` to avoid a greater migration. Static interop APIs, |
| either through `dart:js_interop` or the `@staticInterop` annotation, have used |
| JavaScript's `globalThis` as the global context. This is relevant to things |
| like external top-level members or external constructors, as this is the root |
| context we expect those members to reside in. Historically, this was not the |
| case in dart2js and DDC. We used either `self` or DDC's `global` in non-static |
| interop APIs with `package:js`. So, static interop APIs will now use one of |
| those global contexts. Functionally, this should matter in only a very small |
| number of cases, like when using older browser versions. `dart:js_interop`'s |
| `globalJSObject` is also renamed to `globalContext` and returns the global |
| context used in the lowerings. |
| - **Breaking Change on Types of `dart:js_interop` External APIs**: |
| External JS interop APIs when using `dart:js_interop` are restricted to a set |
| of allowed types. Namely, this includes the primitive types like `String`, JS |
| types from `dart:js_interop`, and other static interop types (either through |
| `@staticInterop` or extension types). |
| - **Breaking Change on `dart:js_interop` `isNull` and `isUndefined`**: |
| `null` and `undefined` can only be discerned in the JS backends. dart2wasm |
| conflates the two values and treats them both as Dart null. Therefore, these |
| two helper methods should not be used on dart2wasm and will throw to avoid |
| potentially erroneous code. |
| - **Breaking Change on `dart:js_interop` `typeofEquals` and `instanceof`**: |
| Both APIs now return a `bool` instead of a `JSBoolean`. `typeofEquals` also |
| now takes in a `String` instead of a `JSString`. |
| - **Breaking Change on `dart:js_interop` `JSAny` and `JSObject`**: |
| These types can only be implemented, and no longer extended, by user |
| `@staticInterop` types. |
| - **Breaking Change on `dart:js_interop` `JSArray.withLength`**: |
| This API now takes in an `int` instead of `JSNumber`. |
| |
| ### Tools |
| |
| #### Development JavaScript compiler (DDC) |
| |
| - Applications compiled by DDC will no longer add members to the native |
| JavaScript Object prototype. |
| - **Breaking change for JS interop with Symbols and BigInts**: |
| JavaScript `Symbol`s and `BigInt`s are now associated with their own |
| interceptor and should not be used with `package:js` classes. These types were |
| being intercepted with the assumption that they are a subtype of JavaScript's |
| `Object`, but this is incorrect. This lead to erroneous behavior when using |
| these types as Dart `Object`s. See [#53106][] for more details. Use |
| `dart:js_interop`'s `JSSymbol` and `JSBigInt` with extension types to interop |
| with these types. |
| |
| #### Production JavaScript compiler (dart2js) |
| |
| - **Breaking change for JS interop with Symbols and BigInts**: |
| JavaScript `Symbol`s and `BigInt`s are now associated with their own |
| interceptor and should not be used with `package:js` classes. These types were |
| being intercepted with the assumption that they are a subtype of JavaScript's |
| `Object`, but this is incorrect. This lead to erroneous behavior when using |
| these types as Dart `Object`s. See [#53106][] for more details. Use |
| `dart:js_interop`'s `JSSymbol` and `JSBigInt` with extension types to interop |
| with these types. |
| |
| [#53106]: https://github.com/dart-lang/sdk/issues/53106 |
| |
| #### Dart command line |
| |
| - The `dart create` command has a new `cli` template |
| to quickly create Dart command-line applications |
| with basic argument parsing capabilities. |
| To learn more about using the template, |
| run `dart help create`. |
| |
| #### Dart format |
| |
| - Always split enum declarations containing a line comment. |
| - Fix regression in splitting type annotations with library prefixes. |
| - Support `--enable-experiment` command-line option to enable language |
| experiments. |
| |
| #### DevTools |
| |
| - Incorporated the [2.26.1][devtools-2-26-1], [2.27.0][devtools-2-27-0], and |
| [2.28.1][devtools-2-28-1] releases of DevTools. |
| |
| [devtools-2-26-1]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.26.1 |
| [devtools-2-27-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.27.0 |
| [devtools-2-28-1]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.28.1 |
| |
| #### Linter |
| |
| - Added the experimental [`annotate_redeclares`][] lint. |
| - Marked the [`use_build_context_synchronously`][] lint as stable. |
| |
| [`annotate_redeclares`]: https://dart.dev/lints/annotate_redeclares |
| [`use_build_context_synchronously`]: https://dart.dev/lints/use_build_context_synchronously |
| |
| #### Pub |
| |
| - New option `dart pub upgrade --tighten` which will update dependencies' lower |
| bounds in `pubspec.yaml` to match the current version. |
| - The commands `dart pub get`/`add`/`upgrade` will now show if a dependency |
| changed between direct, dev and transitive dependency. |
| - The command `dart pub upgrade` no longer shows unchanged dependencies. |
| |
| ## 3.1.5 - 2023-10-25 |
| |
| This is a patch release that: |
| |
| - Fixes an issue affecting Dart compiled to JavaScript running in Node.js 21. A |
| change in Node.js 21 affected the Dart Web compiler runtime. This patch |
| release accommodates for those changes (issue #53810). |
| |
| [#53810]: https://github.com/dart-lang/sdk/issues/53810 |
| |
| ## 3.1.4 - 2023-10-18 |
| |
| This is a patch release that: |
| |
| - Fixes an issue in the Dart VM, users are not being able to see |
| value of variables while debugging code (issue [#53747]). |
| |
| [#53654]: https://github.com/dart-lang/sdk/issues/53747 |
| |
| ## 3.1.3 - 2023-09-27 |
| |
| This is a patch release that: |
| |
| - Fixes a bug in dart2js which would cause the compiler to crash when using |
| `@staticInterop` `@anonymous` factory constructors with type parameters (see |
| issue [#53579] for more details). |
| |
| - The standalone Dart VM now exports symbols only for the Dart_* embedding API |
| functions, avoiding conflicts with other DSOs loaded into the same process, |
| such as shared libraries loaded through `dart:ffi`, that may have different |
| versions of the same symbols (issue [#53503]). |
| |
| - Fixes an issue with super slow access to variables while debugging. |
| The fix avoids searching static functions in the imported libraries |
| as references to members are fully resolved by the front-end. (issue |
| [#53541]) |
| |
| [#53579]: https://github.com/dart-lang/sdk/issues/53579 |
| [#53267]: https://github.com/dart-lang/sdk/issues/53503 |
| [#53541]: https://github.com/dart-lang/sdk/issues/53541 |
| |
| ## 3.1.2 - 2023-09-13 |
| |
| This is a patch release that: |
| |
| - Fixes a bug in dart2js which crashed the compiler when a typed record pattern |
| was used outside the scope of a function body, such as in a field initializer. |
| For example `final x = { for (var (int a,) in someList) a: a };` |
| (issue [#53449]) |
| |
| - Fixes an expedient issue of users seeing an unhandled |
| exception pause in the debugger, please see |
| https://github.com/dart-lang/sdk/issues/53450 for more |
| details. |
| The fix uses try/catch in lookupAddresses instead of |
| Future error so that we don't see an unhandled exception |
| pause in the debugger (issue [#53450]) |
| |
| [#53449]: https://github.com/dart-lang/sdk/issues/53449 |
| [#53450]: https://github.com/dart-lang/sdk/issues/53450 |
| |
| ## 3.1.1 - 2023-09-07 |
| |
| This is a patch release that: |
| |
| - Fixes a bug in the parser which prevented a record pattern from containing a |
| nested record pattern, where the nested record pattern uses record |
| destructuring shorthand syntax, for example `final ((:a, :b), c) = record;` |
| (issue [#53352]). |
| |
| [#53352]: https://github.com/dart-lang/sdk/issues/53352 |
| |
| ## 3.1.0 - 2023-08-16 |
| |
| ### Libraries |
| |
| #### `dart:async` |
| |
| - **Breaking change** [#52334][]: |
| - Added the `interface` modifier to purely abstract classes: |
| `MultiStreamController`, `StreamConsumer`, `StreamIterator` and |
| `StreamTransformer`. As a result, these types can only be implemented, |
| not extended or mixed in. |
| |
| [#52334]: https://github.com/dart-lang/sdk/issues/52334 |
| |
| #### `dart:core` |
| |
| - `Uri.base` on native platforms now respects `IOOverrides` overriding |
| current directory ([#39796][]). |
| |
| [#39796]: https://github.com/dart-lang/sdk/issues/39796 |
| |
| #### `dart:ffi` |
| |
| - Added the `NativeCallable` class, which can be used to create callbacks that |
| allow native code to call into Dart code from any thread. See |
| `NativeCallable.listener`. In future releases, `NativeCallable` will be |
| updated with more functionality, and will become the recommended way of |
| creating native callbacks for all use cases, replacing `Pointer.fromFunction`. |
| |
| #### `dart:io` |
| |
| - **Breaking change** [#51486][]: |
| - Added `sameSite` to the `Cookie` class. |
| - Added class `SameSite`. |
| - **Breaking change** [#52027][]: `FileSystemEvent` is |
| [`sealed`](https://dart.dev/language/class-modifiers#sealed). This means |
| that `FileSystemEvent` cannot be extended or implemented. |
| - Added a deprecation warning when `Platform` is instantiated. |
| - Added `Platform.lineTerminator` which exposes the character or characters |
| that the operating system uses to separate lines of text, e.g., |
| `"\r\n"` on Windows. |
| |
| [#51486]: https://github.com/dart-lang/sdk/issues/51486 |
| [#52027]: https://github.com/dart-lang/sdk/issues/52027 |
| |
| #### `dart:js_interop` |
| |
| - **Object literal constructors**: |
| `ObjectLiteral` is removed from `dart:js_interop`. It's no longer needed in |
| order to declare an object literal constructor with inline classes. As long as |
| an external constructor has at least one named parameter, it'll be treated as |
| an object literal constructor. If you want to create an object literal with no |
| named members, use `{}.jsify()`. |
| |
| ### Other libraries |
| |
| #### `package:js` |
| |
| - **Breaking change to `@staticInterop` and `external` extension members**: |
| `external` `@staticInterop` members and `external` extension members can no |
| longer be used as tear-offs. Declare a closure or a non-`external` method that |
| calls these members, and use that instead. |
| - **Breaking change to `@staticInterop` and `external` extension members**: |
| `external` `@staticInterop` members and `external` extension members will |
| generate slightly different JS code for methods that have optional parameters. |
| Whereas before, the JS code passed in the default value for missing optionals, |
| it will now pass in only the provided members. This aligns with how JS |
| parameters work, where omitted parameters are actually omitted. For example, |
| calling `external void foo([int a, int b])` as `foo(0)` will now result in |
| `foo(0)`, and not `foo(0, null)`. |
| |
| ### Tools |
| |
| #### DevTools |
| |
| - Incorporated the [2.24.0][devtools-2-24-0] and [2.25.0][devtools-2-25-0] |
| releases of DevTools. |
| |
| [devtools-2-24-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.24.0 |
| [devtools-2-25-0]: https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.25.0 |
| |
| #### Linter |
| |
| - Added new static analysis lints you can [enable][enable-lints] in |
| your package's `analysis_options.yaml` file: |
| - [`no_self_assignments`](https://dart.dev/lints/no_self_assignments) |
| - [`no_wildcard_variable_uses`](https://dart.dev/lints/no_wildcard_variable_uses) |
| |
| [enable-lints]: https://dart.dev/tools/analysis#enabling-linter-rules |
| |
| ## 3.0.7 - 2023-07-26 |
| |
| This is a patch release that: |
| |
| - Fixes a bug in dart2js which would cause certain uses of records to lead to |
| bad codegen causing a `TypeError` or `NoSuchMethodError` to be thrown |
| at runtime (issue [#53001]). |
| |
| [#53001]: https://github.com/dart-lang/sdk/issues/53001 |
| |
| ## 3.0.6 - 2023-07-12 |
| |
| This is a patch release that: |
| |
| - Fixes a flow in flow analysis that causes it to sometimes ignore destructuring |
| assignments (issue [#52767]). |
| - Fixes an infinite loop in some web development compiles that include `is` or |
| `as` expressions involving record types with named fields (issue [#52869]). |
| - Fixes a memory leak in Dart analyzer's file-watching (issue [#52791]). |
| - Fixes a memory leak of file system watcher related data structures (issue [#52793]). |
| |
| [#52767]: https://github.com/dart-lang/sdk/issues/52767 |
| [#52869]: https://github.com/dart-lang/sdk/issues/52869 |
| [#52791]: https://github.com/dart-lang/sdk/issues/52791 |
| [#52793]: https://github.com/dart-lang/sdk/issues/52793 |
| |
| ## 3.0.5 - 2023-06-14 |
| |
| This is a patch release that: |
| |
| - Fixes a bad cast in the frontend which can manifest as a crash in the dart2js |
| `ListFactorySpecializer` during Flutter web builds (issue [#52403]). |
| |
| [#52403]: https://github.com/dart-lang/sdk/issues/52403 |
| |
| ## 3.0.4 - 2023-06-07 |
| |
| This is a patch release that: |
| |
| - `dart format` now handles formatting nullable record types |
| with no fields (dart_style issue [#1224]). |
| - Fixes error when using records when targeting the web in development mode |
| (issue [#52480]). |
| |
| [#1224]: https://github.com/dart-lang/dart_style/issues/1224 |
| [#52480]: https://github.com/dart-lang/sdk/issues/52480 |
| |
| ## 3.0.3 - 2023-02-07 |
| |
| This is a patch release that: |
| |
| - Fixes an AOT compiler crash when generating an implicit getter |
| returning an unboxed record (issue [#52449]). |
| - Fixes a situation in which variables appearing in multiple branches of an |
| or-pattern might be erroneously reported as being mismatched (issue [#52373]). |
| - Adds missing `interface` modifiers on the purely abstract classes |
| `MultiStreamController`, `StreamConsumer`, `StreamIterator` and |
| `StreamTransformer` (issue [#52334]). |
| - Fixes an error during debugging when `InternetAddress.tryParse` is |
| used (issue [#52423]). |
| - Fixes a VM issue causing crashes on hot reload (issue [#126884]). |
| - Improves linter support (issue [#4195]). |
| - Fixes an issue in variable patterns preventing users from expressing |
| a pattern match using a variable or wildcard pattern with a nullable |
| record type (issue [#52439]). |
| - Updates warnings and provide instructions for updating the Dart pub |
| cache on Windows (issue [#52386]). |
| |
| [#52373]: https://github.com/dart-lang/sdk/issues/52373 |
| [#52334]: https://github.com/dart-lang/sdk/issues/52334 |
| [#52423]: https://github.com/dart-lang/sdk/issues/52423 |
| [#126884]: https://github.com/flutter/flutter/issues/126884 |
| [#4195]: https://github.com/dart-lang/linter/issues/4195 |
| [#52439]: https://github.com/dart-lang/sdk/issues/52439 |
| [#52449]: https://github.com/dart-lang/sdk/issues/52449 |
| [#52386]: https://github.com/dart-lang/sdk/issues/52386 |
| |
| ## 3.0.2 - 2023-05-24 |
| |
| This is a patch release that: |
| |
| - Fixes a dart2js crash when using a switch case expression on a record where |
| the fields don't match the cases (issue [#52438]). |
| - Add class modifier chips on class and mixin pages |
| generated with `dart doc` (issue [#3392]). |
| - Fixes a situation causing the parser to fail resulting in an infinite loop |
| leading to higher memory usage (issue [#52352]). |
| - Add clear errors when mixing inheritance in pre and post Dart 3 libraries |
| (issue: [#52078]). |
| |
| [#52438]: https://github.com/dart-lang/sdk/issues/52438 |
| [#3392]: https://github.com/dart-lang/dartdoc/issues/3392 |
| [#52352]: https://github.com/dart-lang/sdk/issues/52352 |
| [#52078]: https://github.com/dart-lang/sdk/issues/52078 |
| |
| ## 3.0.1 - 2023-05-17 |
| |
| This is a patch release that: |
| |
| - Fixes a compiler crash involving redirecting factories and FFI |
| (issue [#124369]). |
| - Fixes a dart2js crash when using a combination of local functions, generics, |
| and records (issue [#51899]). |
| - Fixes incorrect error using a `void` in a switch case expression |
| (issue [#52191]). |
| - Fixes a false error when using in switch case expressions when the switch |
| refers to a private getter (issue [#52041]). |
| - Prevent the use of `when` and `as` as variable names in patterns |
| (issue [#52260]). |
| - Fixes an inconsistency in type promotion between the analyzer and VM |
| (issue [#52241]). |
| - Improve performance on functions with many parameters (issue [#1212]). |
| |
| [#124369]: https://github.com/flutter/flutter/issues/124369 |
| [#51899]: https://github.com/dart-lang/sdk/issues/51899 |
| [#52191]: https://github.com/dart-lang/sdk/issues/52191 |
| [#52041]: https://github.com/dart-lang/sdk/issues/52041 |
| [#52260]: https://github.com/dart-lang/sdk/issues/52260 |
| [#52241]: https://github.com/dart-lang/sdk/issues/52241 |
| [#1212]: https://github.com/dart-lang/dart_style/issues/1212 |
| |
| ## 3.0.0 - 2023-05-10 |
| |
| ### Language |
| |
| Dart 3.0 adds the following features. To use them, set your package's [SDK |
| constraint][language version] lower bound to 3.0 or greater (`sdk: '^3.0.0'`). |
| |
| [language version]: https://dart.dev/guides/language/evolution |
| |
| - **[Records]**: Records are anonymous immutable data structures that let you |
| aggregate multiple values together, similar to [tuples][] in other languages. |
| With records, you can return multiple values from a function, create composite |
| map keys, or use them any other place where you want to bundle a couple of |
| objects together. |
| |
| For example, using a record to return two values: |
| |
| ```dart |
| (double x, double y) geoLocation(String name) { |
| if (name == 'Nairobi') { |
| return (-1.2921, 36.8219); |
| } else { |
| ... |
| } |
| } |
| ``` |
| |
| - **[Pattern matching]**: Expressions build values out of smaller pieces. |
| Conversely, patterns are an expressive tool for decomposing values back into |
| their constituent parts. Patterns can call getters on an object, access |
| elements from a list, pull fields out of a record, etc. For example, we can |
| destructure the record from the previous example like so: |
| |
| ```dart |
| var (lat, long) = geoLocation('Nairobi'); |
| print('Nairobi is at $lat, $long.'); |
| ``` |
| |
| Patterns can also be used in [switch cases]. There, you can destructure values |
| and also test them to see if they have a certain type or value: |
| |
| ```dart |
| switch (object) { |
| case [int a]: |
| print('A list with a single integer element $a'); |
| case ('name', _): |
| print('A two-element record whose first field is "name".'); |
| default: print('Some other object.'); |
| } |
| ``` |
| |
| Also, as you can see, non-empty switch cases no longer need `break;` |
| statements. |
| |
| **Breaking change**: Dart 3.0 interprets [switch cases] as patterns instead of |
| constant expressions. Most constant expressions found in switch cases are |
| valid patterns with the same meaning (named constants, literals, etc.). You |
| may need to tweak a few constant expressions to make them valid. This only |
| affects libraries that have upgraded to language version 3.0. |
| |
| - **[Switch expressions]**: Switch expressions allow you to use patterns and |
| multi-way branching in contexts where a statement isn't allowed: |
| |
| ```dart |
| return TextButton( |
| onPressed: _goPrevious, |
| child: Text(switch (page) { |
| 0 => 'Exit story', |
| 1 => 'First page', |
| _ when page == _lastPage => 'Start over', |
| _ => 'Previous page', |
| }), |
| ); |
| ``` |
| |
| - **[If-case statements and elements]**: A new if construct that matches a value |
| against a pattern and executes the then or else branch depending on whether |
| the pattern matches: |
| |
| ```dart |
| if (json case ['user', var name]) { |
| print('Got user message for user $name.'); |
| } |
| ``` |
| |
| There is also a corresponding [if-case element] that can be used in collection |
| literals. |
| |
| - **[Sealed classes]**: When you mark a type `sealed`, the compiler ensures that |
| switches on values of that type [exhaustively cover] every subtype. This |
| enables you to program in an [algebraic datatype][] style with the |
| compile-time safety you expect: |
| |
| ```dart |
| sealed class Amigo {} |
| class Lucky extends Amigo {} |
| class Dusty extends Amigo {} |
| class Ned extends Amigo {} |
| |
| String lastName(Amigo amigo) => |
| switch (amigo) { |
| Lucky _ => 'Day', |
| Ned _ => 'Nederlander', |
| }; |
| ``` |
| |
| In this last example, the compiler reports an error that the switch doesn't |
| cover the subclass `Dusty`. |
| |
| - **[Class modifiers]**: New modifiers `final`, `interface`, `base`, and `mixin` |
| on `class` and `mixin` declarations let you control how the type can be used. |
| By default, Dart is flexible in that a single class declaration can be used as |
| an interface, a superclass, or even a mixin. This flexibility can make it |
| harder to evolve an API over time without breaking users. We mostly keep the |
| current flexible defaults, but these new modifiers give you finer-grained |
| control over how the type can be used. |
| |
| **Breaking change:** Class declarations from libraries that have been upgraded |
| to Dart 3.0 can no longer be used as mixins by default. If you want the class |
| to be usable as both a class and a mixin, mark it [`mixin class`][mixin |
| class]. If you want it to be used only as a mixin, make it a `mixin` |
| declaration. If you haven't upgraded a class to Dart 3.0, you can still use it |
| as a mixin. |
| |
| - **Breaking change** [#50902][]: Dart reports a compile-time error if a |
| `continue` statement targets a [label] that is not a loop (`for`, `do` and |
| `while` statements) or a `switch` member. Fix this by changing the `continue` |
| to target a valid labeled statement. |
| |
| - **Breaking change** [language/#2357][]: Starting in language version 3.0, |
| Dart reports a compile-time error if a colon (`:`) is used as the |
| separator before the default value of an optional named parameter. |
| Fix this by changing the colon (`:`) to an equal sign (`=`). |
| |
| [records]: https://dart.dev/language/records |
| [tuples]: https://en.wikipedia.org/wiki/Tuple |
| [pattern matching]: https://dart.dev/language/patterns |
| [switch cases]: https://dart.dev/language/branches#switch |
| [switch expressions]: https://dart.dev/language/branches#switch-expressions |
| [if-case statements and elements]: https://dart.dev/language/branches#if-case |
| [if-case element]: https://dart.dev/language/collections#control-flow-operators |
| [sealed classes]: https://dart.dev/language/class-modifiers#sealed |
| [exhaustively cover]: https://dart.dev/language/branches#exhaustiveness-checking |
| [algebraic datatype]: https://en.wikipedia.org/wiki/Algebraic_data_type |
| [class modifiers]: https://dart.dev/language/class-modifiers |
| [mixin class]: https://dart.dev/language/mixins#class-mixin-or-mixin-class |
| [#50902]: https://github.com/dart-lang/sdk/issues/50902 |
| [label]: https://dart.dev/language/branches#switch |
| [language/#2357]: https://github.com/dart-lang/language/issues/2357 |
| |
| ### Libraries |
| |
| #### General changes |
| |
| - **Breaking Change**: Non-`mixin` classes in the platform libraries |
| can no longer be mixed in, unless they are explicitly marked as `mixin class`. |
| The following existing classes have been made mixin classes: |
| * `Iterable` |
| * `IterableMixin` (now alias for `Iterable`) |
| * `IterableBase` (now alias for `Iterable`) |
| * `ListMixin` |
| * `SetMixin` |
| * `MapMixin` |
| * `LinkedListEntry` |
| * `StringConversionSink` |
| |
| #### `dart:core` |
| - Added `bool.parse` and `bool.tryParse` static methods. |
| - Added `DateTime.timestamp()` constructor to get current time as UTC. |
| - The type of `RegExpMatch.pattern` is now `RegExp`, not just `Pattern`. |
| |
| - **Breaking change** [#49529][]: |
| - Removed the deprecated `List` constructor, as it wasn't null safe. |
| Use list literals (e.g. `[]` for an empty list or `<int>[]` for an empty |
| typed list) or [`List.filled`][]. |
| - Removed the deprecated `onError` argument on [`int.parse`][], [`double.parse`][], |
| and [`num.parse`][]. Use the [`tryParse`][] method instead. |
| - Removed the deprecated [`proxy`][] and [`Provisional`][] annotations. |
| The original `proxy` annotation has no effect in Dart 2, |
| and the `Provisional` type and [`provisional`][] constant |
| were only used internally during the Dart 2.0 development process. |
| - Removed the deprecated [`Deprecated.expires`][] getter. |
| Use [`Deprecated.message`][] instead. |
| - Removed the deprecated [`CastError`][] error. |
| Use [`TypeError`][] instead. |
| - Removed the deprecated [`FallThroughError`][] error. The kind of |
| fall-through previously throwing this error was made a compile-time |
| error in Dart 2.0. |
| - Removed the deprecated [`NullThrownError`][] error. This error is never |
| thrown from null safe code. |
| - Removed the deprecated [`AbstractClassInstantiationError`][] error. It was made |
| a compile-time error to call the constructor of an abstract class in Dart 2.0. |
| - Removed the deprecated [`CyclicInitializationError`]. Cyclic dependencies are |
| no longer detected at runtime in null safe code. Such code will fail in other |
| ways instead, possibly with a StackOverflowError. |
| - Removed the deprecated [`NoSuchMethodError`][] default constructor. |
| Use the [`NoSuchMethodError.withInvocation`][] named constructor instead. |
| - Removed the deprecated [`BidirectionalIterator`][] class. |
| Existing bidirectional iterators can still work, they just don't have |
| a shared supertype locking them to a specific name for moving backwards. |
| |
| - **Breaking change when migrating code to Dart 3.0**: |
| Some changes to platform libraries only affect code when that code is migrated |
| to language version 3.0. |
| - The `Function` type can no longer be implemented, extended or mixed in. |
| Since Dart 2.0 writing `implements Function` has been allowed |
| for backwards compatibility, but it has not had any effect. |
| In Dart 3.0, the `Function` type is `final` and cannot be subtyped, |
| preventing code from mistakenly assuming it works. |
| - The following declarations can only be implemented, not extended: |
| * `Comparable` |
| * `Exception` |
| * `Iterator` |
| * `Pattern` |
| * `Match` |
| * `RegExp` |
| * `RegExpMatch` |
| * `StackTrace` |
| * `StringSink` |
| |
| None of these declarations contained any implementation to inherit, |
| and are marked as `interface` to signify that they are only intended |
| as interfaces. |
| - The following declarations can no longer be implemented or extended: |
| * `MapEntry` |
| * `OutOfMemoryError` |
| * `StackOverflowError` |
| * `Expando` |
| * `WeakReference` |
| * `Finalizer` |
| |
| The `MapEntry` value class is restricted to enable later optimizations. |
| The remaining classes are tightly coupled to the platform and not |
| intended to be subclassed or implemented. |
| |
| [#49529]: https://github.com/dart-lang/sdk/issues/49529 |
| [`List.filled`]: https://api.dart.dev/stable/2.18.6/dart-core/List/List.filled.html |
| [`int.parse`]: https://api.dart.dev/stable/2.18.4/dart-core/int/parse.html |
| [`double.parse`]: https://api.dart.dev/stable/2.18.4/dart-core/double/parse.html |
| [`num.parse`]: https://api.dart.dev/stable/2.18.4/dart-core/num/parse.html |
| [`tryParse`]: https://api.dart.dev/stable/2.18.4/dart-core/num/tryParse.html |
| [`Deprecated.expires`]: https://api.dart.dev/stable/2.18.4/dart-core/Deprecated/expires.html |
| [`Deprecated.message`]: https://api.dart.dev/stable/2.18.4/dart-core/Deprecated/message.html |
| [`AbstractClassInstantiationError`]: https://api.dart.dev/stable/2.17.4/dart-core/AbstractClassInstantiationError-class.html |
| [`CastError`]: https://api.dart.dev/stable/2.17.4/dart-core/CastError-class.html |
| [`FallThroughError`]: https://api.dart.dev/stable/2.17.4/dart-core/FallThroughError-class.html |
| [`NoSuchMethodError`]: https://api.dart.dev/stable/2.18.4/dart-core/NoSuchMethodError/NoSuchMethodError.html |
| [`NoSuchMethodError.withInvocation`]: https://api.dart.dev/stable/2.18.4/dart-core/NoSuchMethodError/NoSuchMethodError.withInvocation.html |
| [`CyclicInitializationError`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/CyclicInitializationError-class.html |
| [`Provisional`]: https://api.dart.dev/stable/2.18.4/dart-core/Provisional-class.html |
| [`provisional`]: https://api.dart.dev/stable/2.18.4/dart-core/provisional-constant.html |
| [`proxy`]: https://api.dart.dev/stable/2.18.4/dart-core/proxy-constant.html |
| [`CastError`]: https://api.dart.dev/stable/2.18.3/dart-core/CastError-class.html |
| [`TypeError`]: https://api.dart.dev/stable/2.18.3/dart-core/TypeError-class.html |
| [`FallThroughError`]: https://api.dart.dev/dev/2.19.0-374.0.dev/dart-core/FallThroughError-class.html |
| [`NullThrownError`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/NullThrownError-class.html |
| [`AbstractClassInstantiationError`]: https://api.dart.dev/stable/2.18.3/dart-core/AbstractClassInstantiationError-class.html |
| [`CyclicInitializationError`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/CyclicInitializationError-class.html |
| [`BidirectionalIterator`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/BidirectionalIterator-class.html |
| |
| #### `dart:async` |
| |
| - Added extension member `wait` on iterables and 2-9 tuples of futures. |
| |
| - **Breaking change** [#49529][]: |
| - Removed the deprecated [`DeferredLibrary`][] class. |
| Use the [`deferred as`][] import syntax instead. |
| |
| [#49529]: https://github.com/dart-lang/sdk/issues/49529 |
| [`DeferredLibrary`]: https://api.dart.dev/stable/2.18.4/dart-async/DeferredLibrary-class.html |
| [`deferred as`]: https://dart.dev/language/libraries#deferred-loading |
| |
| #### `dart:collection` |
| |
| - Added extension members `nonNulls`, `firstOrNull`, `lastOrNull`, |
| `singleOrNull`, `elementAtOrNull` and `indexed` on `Iterable`s. |
| Also exported from `dart:core`. |
| - Deprecated the `HasNextIterator` class ([#50883][]). |
| |
| - **Breaking change when migrating code to Dart 3.0**: |
| Some changes to platform libraries only affect code when it is migrated |
| to language version 3.0. |
| - The following interface can no longer be extended, only implemented: |
| * `Queue` |
| - The following implementation classes can no longer be implemented: |
| * `LinkedList` |
| * `LinkedListEntry` |
| - The following implementation classes can no longer be implemented |
| or extended: |
| * `HasNextIterator` (Also deprecated.) |
| * `HashMap` |
| * `LinkedHashMap` |
| * `HashSet` |
| * `LinkedHashSet` |
| * `DoubleLinkedQueue` |
| * `ListQueue` |
| * `SplayTreeMap` |
| * `SplayTreeSet` |
| |
| [#50883]: https://github.com/dart-lang/sdk/issues/50883 |
| |
| #### `dart:developer` |
| |
| - **Breaking change** [#49529][]: |
| - Removed the deprecated [`MAX_USER_TAGS`][] constant. |
| Use [`maxUserTags`][] instead. |
| - Callbacks passed to `registerExtension` will be run in the zone from which |
| they are registered. |
| |
| - **Breaking change** [#50231][]: |
| - Removed the deprecated [`Metrics`][], [`Metric`][], [`Counter`][], |
| and [`Gauge`][] classes as they have been broken since Dart 2.0. |
| |
| [#49529]: https://github.com/dart-lang/sdk/issues/49529 |
| [#50231]: https://github.com/dart-lang/sdk/issues/50231 |
| [`MAX_USER_TAGS`]: https://api.dart.dev/stable/2.19.6/dart-developer/UserTag/MAX_USER_TAGS-constant.html |
| [`maxUserTags`]: https://api.dart.dev/beta/2.19.0-255.2.beta/dart-developer/UserTag/maxUserTags-constant.html |
| [`Metrics`]: https://api.dart.dev/stable/2.18.2/dart-developer/Metrics-class.html |
| [`Metric`]: https://api.dart.dev/stable/2.18.2/dart-developer/Metric-class.html |
| [`Counter`]: https://api.dart.dev/stable/2.18.2/dart-developer/Counter-class.html |
| [`Gauge`]: https://api.dart.dev/stable/2.18.2/dart-developer/Gauge-class.html |
| |
| #### `dart:ffi` |
| |
| - The experimental `@FfiNative` annotation is now deprecated. |
| Usages should be replaced with the new `@Native` annotation. |
| |
| #### `dart:html` |
| |
| - **Breaking change**: As previously announced, the deprecated `registerElement` |
| and `registerElement2` methods in `Document` and `HtmlDocument` have been |
| removed. See [#49536](https://github.com/dart-lang/sdk/issues/49536) for |
| details. |
| |
| #### `dart:math` |
| |
| - **Breaking change when migrating code to Dart 3.0**: |
| Some changes to platform libraries only affect code when it is migrated |
| to language version 3.0. |
| - The `Random` interface can only be implemented, not extended. |
| |
| #### `dart:io` |
| |
| - Added `name` and `signalNumber` to the `ProcessSignal` class. |
| - Deprecate `NetworkInterface.listSupported`. Has always returned true since |
| Dart 2.3. |
| - Finalize `httpEnableTimelineLogging` parameter name transition from `enable` |
| to `enabled`. See [#43638][]. |
| - Favor IPv4 connections over IPv6 when connecting sockets. See |
| [#50868]. |
| - **Breaking change** [#51035][]: |
| - Update `NetworkProfiling` to accommodate new `String` ids |
| that are introduced in vm_service:11.0.0 |
| |
| [#43638]: https://github.com/dart-lang/sdk/issues/43638 |
| [#50868]: https://github.com/dart-lang/sdk/issues/50868 |
| [#51035]: https://github.com/dart-lang/sdk/issues/51035 |
| |
| #### `dart:js_util` |
| |
| - Added several helper functions to access more JavaScript operators, like |
| `delete` and the `typeof` functionality. |
| - `jsify` is now permissive and has inverse semantics to `dartify`. |
| - `jsify` and `dartify` both handle types they understand natively more |
| efficiently. |
| - Signature of `callMethod` has been aligned with the other methods and |
| now takes `Object` instead of `String`. |
| |
| ### Tools |
| |
| #### Observatory |
| - Observatory is no longer served by default and users should instead use Dart |
| DevTools. Users requiring specific functionality in Observatory should set |
| the `--serve-observatory` flag. |
| |
| #### Web Dev Compiler (DDC) |
| - Removed deprecated command line flags `-k`, `--kernel`, and `--dart-sdk`. |
| - The compile time flag `--nativeNonNullAsserts`, which ensures web library APIs |
| are sound in their nullability, is by default set to true in sound mode. For |
| more information on the flag, see [NATIVE_NULL_ASSERTIONS.md][]. |
| |
| [NATIVE_NULL_ASSERTIONS.md]: https://github.com/dart-lang/sdk/blob/main/sdk/lib/html/doc/NATIVE_NULL_ASSERTIONS.md |
| |
| #### dart2js |
| - The compile time flag `--native-null-assertions`, which ensures web library |
| APIs are sound in their nullability, is by default set to true in sound mode, |
| unless `-O3` or higher is passed, in which case they are not checked. For more |
| information on the flag, see [NATIVE_NULL_ASSERTIONS.md][]. |
| |
| [NATIVE_NULL_ASSERTIONS.md]: https://github.com/dart-lang/sdk/blob/main/sdk/lib/html/doc/NATIVE_NULL_ASSERTIONS.md |
| |
| #### Dart2js |
| |
| - Cleanup related to [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| the internal dart2js snapshot fails unless it is called from a supported |
| interface, such as `dart compile js`, `flutter build`, or |
| `build_web_compilers`. This is not expected to be a visible change. |
| |
| #### Formatter |
| |
| * Format `sync*` and `async*` functions with `=>` bodies. |
| * Don't split after `<` in collection literals. |
| * Better indentation of multiline function types inside type argument lists. |
| * Fix bug where parameter metadata wouldn't always split when it should. |
| |
| #### Analyzer |
| |
| - Most static analysis "hints" are converted to be "warnings," and any |
| remaining hints are intended to be converted soon after the Dart 3.0 release. |
| This means that any (previously) hints reported by `dart analyze` are now |
| considered "fatal" (will result in a non-zero exit code). The previous |
| behavior, where such hints (now warnings) are not fatal, can be achieved by |
| using the `--no-fatal-warnings` flag. This behavior can also be altered, on a |
| code-by-code basis, by [changing the severity of rules] in an analysis |
| options file. |
| - Add static enforcement of the SDK-only `@Since` annotation. When code in a |
| package uses a Dart SDK element annotated with `@Since`, analyzer will report |
| a warning if the package's [Dart SDK constraint] allows versions of Dart |
| which don't include that element. |
| - Protects the Dart Analysis Server against extreme memory usage by limiting |
| the number of plugins per analysis context to 1. (issue [#50981][]). |
| |
| [changing the severity of rules]: https://dart.dev/tools/analysis#changing-the-severity-of-rules |
| [Dart SDK constraint]: https://dart.dev/tools/pub/pubspec#sdk-constraints |
| |
| #### Linter |
| |
| Updates the Linter to `1.35.0`, which includes changes that |
| |
| - add new lints: |
| - `implicit_reopen` |
| - `unnecessary_breaks` |
| - `type_literal_in_constant_pattern` |
| - `invalid_case_patterns` |
| - update existing lints to support patterns and class modifiers |
| - remove support for: |
| - `enable_null_safety` |
| - `invariant_booleans` |
| - `prefer_bool_in_asserts` |
| - `prefer_equal_for_default_values` |
| - `super_goes_last` |
| - fix `unnecessary_parenthesis` false-positives with null-aware expressions. |
| - fix `void_checks` to allow assignments of `Future<dynamic>?` to parameters |
| typed `FutureOr<void>?`. |
| - fix `use_build_context_synchronously` in if conditions. |
| - fix a false positive for `avoid_private_typedef_functions` with generalized |
| type aliases. |
| - update `unnecessary_parenthesis` to detect some doubled parens. |
| - update `void_checks` to allow returning `Never` as void. |
| - update `no_adjacent_strings_in_list` to support set literals and for- and |
| if-elements. |
| - update `avoid_types_as_parameter_names` to handle type variables. |
| - update `avoid_positional_boolean_parameters` to handle typedefs. |
| - update `avoid_redundant_argument_values` to check parameters of redirecting |
| constructors. |
| - improve performance for `prefer_const_literals_to_create_immutables`. |
| - update `use_build_context_synchronously` to check context properties. |
| - improve `unnecessary_parenthesis` support for property accesses and method |
| invocations. |
| - update `unnecessary_parenthesis` to allow parentheses in more null-aware |
| cascade contexts. |
| - update `unreachable_from_main` to track static elements. |
| - update `unnecessary_null_checks` to not report on arguments passed to |
| `Future.value` or `Completer.complete`. |
| - mark `always_use_package_imports` and `prefer_relative_imports` as |
| incompatible rules. |
| - update `only_throw_errors` to not report on `Never`-typed expressions. |
| - update `unnecessary_lambdas` to not report with `late final` variables. |
| - update `avoid_function_literals_in_foreach_calls` to not report with nullable- |
| typed targets. |
| - add new lint: `deprecated_member_use_from_same_package` which replaces the |
| soft-deprecated analyzer hint of the same name. |
| - update `public_member_api_docs` to not require docs on enum constructors. |
| - update `prefer_void_to_null` to not report on as-expressions. |
| |
| #### Migration tool removal |
| |
| The null safety migration tool (`dart migrate`) has been removed. If you still |
| have code which needs to be migrated to null safety, please run `dart migrate` |
| using Dart version 2.19, before upgrading to Dart version 3.0. |
| |
| #### Pub |
| |
| - To preserve compatibility with null-safe code pre Dart 3, Pub will interpret a |
| language constraint indicating a language version of `2.12` or higher and an |
| upper bound of `<3.0.0` as `<4.0.0`. |
| |
| For example `>=2.19.2 <3.0.0` will be interpreted as `>=2.19.2 <4.0.0`. |
| - `dart pub publish` will no longer warn about `dependency_overrides`. Dependency |
| overrides only take effect in the root package of a resolution. |
| - `dart pub token add` now verifies that the given token is valid for including |
| in a header according to [RFC 6750 section |
| 2.1](https://www.rfc-editor.org/rfc/rfc6750#section-2.1). This means they must |
| contain only the characters: `^[a-zA-Z0-9._~+/=-]+$`. Before a failure would |
| happen when attempting to send the authorization header. |
| - `dart pub get` and related commands will now by default also update the |
| dependencies in the `example` folder (if it exists). Use `--no-example` to |
| avoid this. |
| - On Windows the `PUB_CACHE` has moved to `%LOCALAPPDATA%`, since Dart 2.8 the |
| `PUB_CACHE` has been created in `%LOCALAPPDATA%` when one wasn't present. |
| Hence, this only affects users with a `PUB_CACHE` created by Dart 2.7 or |
| earlier. If you have `path/to/.pub-cache/bin` in `PATH` you may need to |
| update your `PATH`. |
| |
| ## 2.19.6 - 2023-03-29 |
| |
| This is a patch release that: |
| |
| - Fixes an `Out of Memory` exception due to a VM bug. (issue [#50537]). |
| |
| [#50537]: https://github.com/dart-lang/sdk/issues/50537 |
| |
| ## 2.19.5 - 2023-03-22 |
| |
| This is a patch release that: |
| |
| - Fixes broken usage of `Dart_CObject_Type`. (issue [#51459]). |
| |
| [#51459]: https://github.com/dart-lang/sdk/issues/51459 |
| |
| ## 2.19.4 - 2023-03-08 |
| |
| This is a patch release that: |
| |
| - Fixes mobile devices vm crashes caused by particular use of RegExp. (issue |
| [#121270][]). |
| |
| [#121270]: https://github.com/flutter/flutter/issues/121270 |
| |
| ## 2.19.3 - 2023-03-01 |
| |
| This is a patch release that: |
| |
| - Updates DDC test and builder configuration. (issue [#51481][]). |
| |
| - Protects the Dart Analysis Server against extreme memory usage by limiting |
| the number of plugins per analysis context to 1. (issue [#50981][]). |
| |
| [#50981]: https://github.com/dart-lang/sdk/issues/50981 |
| [#51481]: https://github.com/dart-lang/sdk/issues/51481 |
| |
| ## 2.19.2 - 2023-02-08 |
| |
| This is a patch release that: |
| |
| - Fixes a VM crash when mixing the use of double and float calculations in |
| debug/jit configuration. (issue [#50622][]). |
| |
| - Fixes the compiler crashing when attempting to inline a method with lots of |
| optional parameters with distinct default values. (issue [#119220][]). |
| |
| - Fixes the `part_of_different_library` error encountered when using `PackageBuildWorkspace`. (issue [#51087][]). |
| |
| [#50622]: https://github.com/dart-lang/sdk/issues/50622 |
| [#119220]: https://github.com/flutter/flutter/issues/119220 |
| [#51087]: https://github.com/dart-lang/sdk/issues/51087 |
| |
| ## 2.19.1 - 2023-02-01 |
| |
| This is a patch release that: |
| |
| - Fixes `pub get` behaviour: In Dart 2.19.0 a `dart pub get` with a |
| `pubspec.lock` created by a 2.18 SDK will unlock all constraints, effectively |
| like a `pub upgrade` (issue [#51166][]). |
| |
| - Stops rewriting SDK constraints: In Dart 3, a SDK constraint like |
| `>=2.12.0 <3.0.0` gets interpreted by the pub client as `>=2.12.0 <4.0.0` to |
| allow for backwards compatibility (issue [#51101][]). |
| |
| This change was intended for Dart 3.0.0 and later, but was landed already in |
| 2.19.0. It is now being removed in 2.19.1, as it can give confusing messages |
| such as: |
| |
| > Because library requires SDK version >=2.19.2 <4.0.0, version solving failed. |
| |
| This reinterpretation no longer happens in Dart 2.19.1. |
| |
| - Fixes a VM crash caused by incorrect sharing of RegExp between isolates |
| (issue [#51130][]). |
| |
| [#51166]: https://github.com/dart-lang/sdk/issues/51166 |
| [#51101]: https://github.com/dart-lang/sdk/issues/51101 |
| [#51130]: https://github.com/dart-lang/sdk/issues/51130 |
| |
| ## 2.19.0 - 2023-01-24 |
| |
| ### Language |
| |
| - **Breaking change** [#49635][]: Flag additional code as unreachable due to |
| types `Null` and `Never`. Several unusual constructs that lead to unreachable |
| code are now recognized by flow analysis: |
| |
| - Control flow after an expression of the form `e ?? other` or `e ??= other`, |
| where `e` has static type `Null` and `other` has static type `Never`, is |
| considered unreachable. |
| |
| - Control flow predicated on an expression of the form `e is Never` evaluating |
| to `true` is considered unreachable. |
| |
| - Control flow predicated on an expression of the form `e is! Never` |
| evaluating to `false` is considered unreachable. |
| |
| - Control flow on the RHS of a null-aware access such as `e?.property...`, |
| `e?.property = ...` or `e?.method(...)`, where `e` has static type `Null`, |
| is considered unreachable (Note: this can arise in the presence of extension |
| methods). |
| |
| Previously, these behaviors only took effect if `e` was a reference to a local |
| variable. |
| |
| Additionally, a type test of the form `v is Never` (where `v` is a local |
| variable) no longer promotes `v` to type `Never`. |
| |
| [#49635]: https://github.com/dart-lang/sdk/issues/49635 |
| |
| - **Breaking Change** [#49687][]: Don't delegate inaccessible private names to |
| `noSuchMethod`. If a concrete class implements an interface containing a |
| member with a name that's private to different library, and does not inherit |
| an implementation of that interface member, a invocation of that member will |
| result in an exception getting thrown. Previously, such attempts would result |
| in the call being diverted to the `noSuchMethod` method. |
| |
| This change closes a loophole in Dart's privacy system, where another library |
| can provide a different implementation of a supposedly private member using |
| `noSuchMethod`, and paves the way for a future implementation of promotion for |
| private final fields (see [#2020][]). |
| |
| [#49687]: https://github.com/dart-lang/sdk/issues/49687 |
| [#2020]: https://github.com/dart-lang/language/issues/2020 |
| |
| - **Breaking Change** [#50383][]: Report a compile-time error for all cyclic |
| dependencies during top-level type inference. |
| |
| Previously, some of these dependencies were ignored, based on an analysis |
| determining that they could not influence the inferred type. However, this |
| analysis was complex, differed slightly among tools, and had become much more |
| complex due to other changes (especially, enhanced flow analysis). |
| |
| With this change, all tools treat these cyclic dependencies in the same way, |
| the analysis is well-understood, and, arguably, the code is more readable. |
| |
| Breakage is mitigated by adding a declared type to one top-level declaration |
| per cycle which is now an error. |
| |
| [#50383]: https://github.com/dart-lang/sdk/issues/50383 |
| |
| - Add support for **unnamed libraries**. Dart language 2.19 allows a library |
| directive to be written without a name (`library;`). A library directive can |
| be used for library-level annotations (such as `@deprecated`) and for |
| library-level documentation comments, and with this new feature, you don't |
| have to provide a unique name for each library directive. Instead, a name can |
| simply be omitted (see [#1073][]). |
| |
| [#1073]: https://github.com/dart-lang/language/issues/1073 |
| |
| ### Libraries |
| |
| #### `dart:convert` |
| |
| - **Breaking change** [#34233]: The previously deprecated API |
| [`DEFAULT_BUFFER_SIZE`] in `JsonUtf8Encoder` has been removed. |
| |
| [#34233]: https://github.com/dart-lang/sdk/issues/34233 |
| [`DEFAULT_BUFFER_SIZE`]: https://api.dart.dev/stable/2.17.6/dart-convert/JsonUtf8Encoder/DEFAULT_BUFFER_SIZE-constant.html |
| |
| #### `dart:core` |
| |
| - Deprecated `FallThroughError`. Has not been thrown since Dart 2.0 |
| (see [#49529]). |
| - Added `copyWith` extension method on `DateTime` (see [#24644]). |
| - Deprecated `RangeError.checkValidIndex` in favor of `IndexError.check`. |
| - Deprecated `IndexError` constructor in favor of `IndexError.withLength` |
| constructor. |
| - Deprecated `NullThrownError` and `CyclicInitializationError`. |
| Neither error is thrown by null safe code. |
| [#49529]: https://github.com/dart-lang/sdk/issues/49529 |
| [#24644]: https://github.com/dart-lang/sdk/issues/24644 |
| |
| #### `dart:developer` |
| |
| - **Breaking change** [#34233]: The previously deprecated APIs `kInvalidParams`, |
| `kExtensionError`, `kExtensionErrorMax`, and `kExtensionErrorMin` in |
| [`ServiceExtensionResponse`] have been removed. They have been replaced by |
| `invalidParams`, `extensionError`, `extensionErrorMax`, and |
| `extensionErrorMin`. |
| - Deprecated `UserTag.MAX_USER_TAGS` in favor of `UserTag.maxUserTags`. |
| |
| [#34233]: https://github.com/dart-lang/sdk/issues/34233 |
| [`ServiceExtensionResponse`]: https://api.dart.dev/stable/2.17.6/dart-developer/ServiceExtensionResponse-class.html#constants |
| |
| #### `dart:ffi` |
| |
| - **Breaking change** [#49935]: The runtime type argument of `Pointer` has |
| changed to `Never` in preparation of completely removing the runtime type |
| argument. `Pointer.toString` has changed to not report any type argument. |
| |
| [#49935]: https://github.com/dart-lang/sdk/issues/49935 |
| |
| #### `dart:html` |
| |
| - Add constructor and `slice` to `SharedArrayBuffer`. |
| - Deprecated `registerElement` and `registerElement2` in `Document` and |
| `HtmlDocument`. These APIs were based on the deprecated Web Components v0.5 |
| specification and are not supported by browsers today. These APIs are expected |
| to be deleted in a future release. See the related breaking change request |
| [#49536](https://github.com/dart-lang/sdk/issues/49536). |
| |
| #### `dart:io` |
| |
| - **Breaking change** [#49305](https://github.com/dart-lang/sdk/issues/49305): |
| Disallow negative or hexadecimal content-length headers. |
| - **Breaking change** [#49647](https://github.com/dart-lang/sdk/issues/49647): |
| `File.create` now takes new optional `exclusive` `bool` parameter, and when it |
| is `true` the operation will fail if target file already exists. |
| - **Breaking change** [#49878]: Calling `ResourceHandle.toFile()`, |
| `ResourceHandle.toSocket()`, `ResourceHandle.toRawSocket()` or |
| `ResourceHandle.toRawDatagramSocket()`, more than once now throws a |
| `StateError`. |
| |
| The previous behavior would allow multiple Dart objects to refer to the same |
| file descriptor, which would produce errors when one object was closed or |
| garbage collected. |
| |
| [#49878]: https://github.com/dart-lang/sdk/issues/49878 |
| |
| - Adds three new `FileSystemException` subclasses to handle common error cases: |
| |
| - `PathAccessException`: The necessary access rights are not available. |
| - `PathExistsException`: The path being created already exists. |
| - `PathNotFoundException`: The path being accessed does not exist. |
| |
| [#12461]: https://github.com/dart-lang/sdk/issues/12461 |
| [#50436]: https://github.com/dart-lang/sdk/issues/50436 |
| |
| #### `dart:isolate` |
| |
| - Add `Isolate.run` to run a function in a new isolate. |
| - **Breaking change**: `SendPort.send` is again applying strict checks to the |
| contents of the message when sending messages between isolates that are not |
| known to share the same code (e.g. an isolate spawned via `Isolate.spawnUri`). |
| These checks were accidentally relaxed in an earlier Dart version allowing |
| all classes from `dart:core` and `dart:collection` through. This for |
| example means that you can't send an instance of a `HashMap` to an isolate |
| spawned via `Isolate.spawnUri`. See [`SendPort.send`] documentation for |
| the full list of restrictions. |
| |
| [`SendPort.send`]: https://api.dart.dev/stable/dart-isolate/SendPort/send.html |
| |
| #### `dart:mirrors` |
| |
| - **Breaking change** [#34233]: The APIs [`MirrorsUsed`] and [`Comment`] have |
| been removed. `MirrorsUsed` was experimental and deprecated; `Comment` was |
| previously used internally in dart2js. Both are no longer functional. |
| |
| [#34233]: https://github.com/dart-lang/sdk/issues/34233 |
| [`MirrorsUsed`]: https://api.dart.dev/stable/dart-mirrors/MirrorsUsed-class.html |
| [`Comment`]: https://api.dart.dev/stable/dart-mirrors/Comment-class.html |
| |
| ### Other libraries |
| |
| #### `package:js` |
| |
| - **Breaking changes to the preview feature `@staticInterop`**: |
| - Classes with this annotation are now disallowed from using `external` |
| generative constructors. Use `external factory`s for these classes instead, |
| and the behavior should be identical. This includes use of synthetic |
| constructors. See [#48730] and [#49941] for more details. |
| - Classes with this annotation's external extension members are now disallowed |
| from using type parameters e.g. `external void method<T>(T t)`. Use a |
| non-`external` extension method for type parameters instead. See [#49350] |
| for more details. |
| - Classes with this annotation should also have the `@JS` annotation. You can |
| also have the `@anonymous` annotation with these two annotations for an |
| object literal constructor, but it isn't required. |
| - Classes with this annotation can not be implemented by classes without this |
| annotation. This is to avoid confusing type behavior. |
| |
| [#48730]: https://github.com/dart-lang/sdk/issues/48730 |
| [#49941]: https://github.com/dart-lang/sdk/issues/49941 |
| [#49350]: https://github.com/dart-lang/sdk/issues/49350 |
| |
| ### Tools |
| |
| #### Analyzer |
| |
| - add static enforcement of new `mustBeOverridden` annotation, and quick fixes |
| - add quick fixes for many diagnostics including compile-time errors, hints, and |
| lints. There are now quick fixes for over 300 diagnostic codes. These lint |
| rules have new fixes: `combinators_ordering`, `dangling_library_doc_comments`, |
| `implicit_call_tearoffs`, `library_annotations`, and |
| `unnecessary_library_directive`. |
| - add new hints: `body_might_complete_normally_catch_error`, |
| `cast_from_null_always_fails`, `cast_from_nullable_always_fails`, |
| `deprecated_colon_for_default_value`, and `duplicate_export` |
| - remove hint: `invalid_override_different_default_values` |
| |
| #### Linter |
| |
| Updated the Linter to `1.31.0`, which includes changes that |
| |
| - add new lint: `collection_methods_unrelated_type`. |
| - add new lint: `combinators_ordering`. |
| - add new lint: `dangling_library_doc_comments`. |
| - add new lint: `enable_null_safety`. |
| - add new lint: `implicit_call_tearoffs`. |
| - add new lint: `library_annotations`. |
| - add new lint: `unnecessary_library_directive`. |
| - add new lint: `unreachable_from_main`. |
| - add new lint: `use_string_in_part_of_directives`. |
| - fix `no_leading_underscores_for_local_identifiers` to not report super formals |
| as local variables. |
| - fix `unnecessary_overrides` false negatives. |
| - fix `cancel_subscriptions` for nullable fields. |
| - update `library_names` to support unnamed libraries. |
| - fix `unnecessary_parenthesis` support for as-expressions. |
| - fix `use_build_context_synchronously` to check for context property accesses. |
| - fix false positive in `comment_references`. |
| - improved unrelated type checks to handle enums and cascades. |
| - fix `unnecessary_brace_in_string_interps` for `this` expressions . |
| - update `use_build_context_synchronously` for `BuildContext.mounted`. |
| - improve `flutter_style_todos` to handle more cases. |
| - fix `use_build_context_synchronously` to check for `BuildContext`s in named |
| expressions. |
| - fix `exhaustive_cases` to check parenthesized expressions |
| - update `avoid_redundant_argument_values` to work with enum declarations. |
| - fix `avoid_redundant_argument_values` when referencing required |
| parameters in legacy libraries. |
| - fix `use_super_parameters` false positives with repeated super |
| parameter references. |
| - update `use_late_for_private_fields_and_variables` to handle enums. |
| - fix `prefer_contains` false positives when a start index is non-zero. |
| - improve `noop_primitive_operations` to catch `.toString()` |
| in string interpolations. |
| - update `public_member_api_docs` to report diagnostics on extension |
| names (instead of bodies). |
| - fix `use_colored_box` and `use_decorated_box` to not over-report on containers without |
| a child. |
| - fix `unnecessary_parenthesis` false positives on a map-or-set literal at the start of |
| an expression statement. |
| - fix `prefer_final_locals` false positives reporting on fields. |
| - fix `unnecessary_overrides` to allow overrides on `@Protected`members. |
| - fix `avoid_multiple_declarations_per_line` false positives in `for` statements. |
| - fix `prefer_final_locals` false positives on declaration lists with at least one |
| non-final variable. |
| - fix`use_build_context_synchronously` to handle `await`s in `if` conditions. |
| - improves performance for: |
| - `avoid_escaping_inner_quotes`. |
| - `avoid_null_checks_in_equality_operators`. |
| - `avoid_positional_boolean_parameters`. |
| - `avoid_returning_null`. |
| - `avoid_returning_null`. |
| - `avoid_returning_this`. |
| - `cascade_invocations`. |
| - `diagnostic_describe_all_properties`. |
| - `flutter_style_todos`. |
| - `join_return_with_statement`. |
| - `parameter_assignments`. |
| - `prefer_const_constructors`. |
| - `prefer_constructors_over_static_methods`. |
| - `prefer_constructors_over_static_methods`. |
| - `prefer_contains`. |
| - `prefer_foreach`. |
| - `prefer_interpolation_to_compose_strings`. |
| - `prefer_interpolation_to_compose_strings`. |
| - `recursive_getters`. |
| - `tighten_type_of_initializing_formals`. |
| - `unnecessary_lambdas`. |
| - `use_late_for_private_fields_and_variables`. |
| |
| #### Pub |
| |
| - Treats packages with sdk constraint lower bound `>=2.12.0` or more and upper |
| bound `<3.0.0` as compatible with `<4.0.0`. |
| - Introduces content-hashes in pubspec.lock, to protect against corrupted |
| package repositories. |
| |
| These will show up in the lock file on the first run of `dart pub get`. |
| |
| See https://dart.dev/go/content-hashes for more details. |
| - New flag `dart pub get --enforce-lockfile` will fetch dependencies, but fail |
| if anything deviates from `pubspec.lock`. Useful for ensuring reproducible runs |
| in CI and production. |
| - Remove remaining support for `.packages` files. The flag |
| `--legacy-packages-file` is no longer supported. |
| - The client will now default to the `pub.dev` repository instead of `pub.dartlang.org`. |
| This will cause a change in `pubspec.lock`. |
| - Support a new field [`funding`](https://dart.dev/tools/pub/pubspec#funding) in `pubspec.yaml`. |
| - Validate the CRC32c checksum of downloaded archives and retry on failure. |
| - `dart pub add foo:<constraint>` with an existing dependency will now update |
| the constraint rather than fail. |
| - Update `dart pub publish` to allow `dependency_overrides` in `pubspec.yaml`. |
| They will still cause a publication warning. |
| Note that only `dependency_overrides` from the root package effect resolution. |
| - Update `dart pub publish` to require a working resolution. |
| If publishing a breaking release of mutually dependent packages use `dependency_overrides` |
| to obtain a resolution. |
| - `dart pub add` will now allow adding multiple packages from any source using |
| the same YAML syntax as in `pubspec.yaml`. |
| |
| For example: |
| ```console |
| $ dart pub add retry:^1.0.0 'dev:foo{"git":"https://github.com/foo/foo"}' |
| ``` |
| - `dart pub publish` will now give a warning if `dart analyze` reports any diagnostics. |
| - `dart pub get` now fails gracefully when run from inside the pub-cache. |
| - `dart pub publish` now shows the file sizes of large files in your package to |
| prevent accidental publication of large unrelated files. |
| - Fix a bug in `dart pub upgrade --major-versions` where packages not requiring |
| major updates would be held back unless needed. |
| |
| #### dart2js |
| |
| - **Breaking change** [49473](https://github.com/dart-lang/sdk/issues/49473): |
| dart2js no longer supports HTTP URIs as inputs. |
| |
| ## 2.18.5 - 2022-11-23 |
| |
| - fixes an error on private variable setters in mixins on dart web |
| (issue [#50119][]). |
| - fixes the handling of type parameter nullability in factory constructors |
| (issue [#50392][]). |
| |
| [#50119]: https://github.com/dart-lang/sdk/issues/50119 |
| [#50392]: https://github.com/dart-lang/sdk/issues/50392 |
| |
| ## 2.18.4 - 2022-11-02 |
| |
| This is a patch release that fixes crashes during hot reload |
| (issue [flutter/flutter#113540][]). |
| |
| [flutter/flutter#113540]: https://github.com/flutter/flutter/issues/113540 |
| |
| ## 2.18.3 - 2022-10-19 |
| |
| This is a patch release that fixes a regression in code coverage computation |
| (issue [#49887][]). |
| |
| [#49887]: https://github.com/dart-lang/sdk/issues/49887 |
| |
| ## 2.18.2 - 2022-09-28 |
| |
| This is a patch release that: |
| |
| - fixes incorrect behavior in `Uri.parse`. |
| - fixes a compiler crash (issue [#50052][]). |
| |
| ### Libraries |
| |
| #### `dart:core` |
| |
| - **Security advisory** [CVE-2022-3095](https://github.com/dart-lang/sdk/security/advisories/GHSA-m9pm-2598-57rj): |
| There is a auth bypass vulnerability in Dart SDK, specifically `dart:uri` core |
| library, used to parse and validate URLs. This library is vulnerable to the |
| backslash-trick wherein backslash is not recognized as equivalent to forward |
| slash in URLs. |
| |
| The `Uri` class has been changed to parse a backslash in the path or the |
| authority separator of a URI as a forward slash. This affects the `Uri` |
| constructor's `path` parameter, and the `Uri.parse` method. |
| This change was made to not diverge as much from the browser `URL` behavior. |
| The Dart `Uri` class is still not an implementation of the same standard |
| as the browser's `URL` implementation. |
| |
| [#50052]: https://github.com/dart-lang/sdk/issues/50052 |
| |
| ## 2.18.1 - 2022-09-14 |
| |
| This is a patch release that fixes a crash caused by incorrect type inference |
| (issues [flutter/flutter#110715][] and [flutter/flutter#111088][]). |
| |
| [flutter/flutter#110715]: https://github.com/flutter/flutter/issues/110715 |
| [flutter/flutter#111088]: https://github.com/flutter/flutter/issues/111088 |
| |
| ## 2.18.0 - 2022-08-30 |
| |
| ### Language |
| |
| The following features are new in the Dart 2.18 [language version][]. To use |
| them, you must set the lower bound on the SDK constraint for your package to |
| 2.18 or greater (`sdk: '>=2.18.0 <3.0.0'`). |
| |
| [language version]: https://dart.dev/guides/language/evolution |
| |
| - **[Enhanced type inference for generic invocations with function literals][]**: |
| Invocations of generic methods/constructors that supply function literal |
| arguments now have improved type inference. This primarily affects the |
| `Iterable.fold` method. For example, in previous versions of Dart, the |
| compiler would fail to infer an appropriate type for the parameter `a`: |
| |
| ```dart |
| void main() { |
| List<int> ints = [1, 2, 3]; |
| var maximum = ints.fold(0, (a, b) => a < b ? b : a); |
| } |
| ``` |
| |
| With this improvement, `a` receives its type from the initial value, `0`. |
| |
| On rare occasions, the wrong type will be inferred, leading to a compile-time |
| error, for example in this code, type inference will infer that `a` has a |
| type of `Null`: |
| |
| ```dart |
| void main() { |
| List<int> ints = [1, 2, 3]; |
| var maximumOrNull = ints.fold(null, |
| (a, b) => a == null || a < b ? b : a); |
| } |
| ``` |
| |
| This can be worked around by supplying the appropriate type as an explicit |
| type argument to `fold`: |
| |
| ```dart |
| void main() { |
| List<int> ints = [1, 2, 3]; |
| var maximumOrNull = ints.fold<int?>(null, |
| (a, b) => a == null || a < b ? b : a); |
| } |
| ``` |
| [Enhanced type inference for generic invocations with function literals]: https://github.com/dart-lang/language/issues/731 |
| |
| - **Breaking Change** [#48167](https://github.com/dart-lang/sdk/issues/48167): |
| Mixin of classes that don't extend `Object` is no longer supported: |
| ```dart |
| class Base {} |
| class Mixin extends Base {} |
| class C extends Base with Mixin {} |
| ``` |
| This should instead be written using a mixin declaration of `Mixin`: |
| ```dart |
| class Base {} |
| mixin Mixin on Base {} |
| class C extends Base with Mixin {} |
| ``` |
| This feature has not been supported in most compilation targets for some |
| time but is now completely removed. |
| |
| ### Core libraries |
| |
| #### `dart:async` |
| |
| - The `Stream.fromIterable` stream can now be listened to more than once. |
| |
| #### `dart:collection` |
| |
| - Deprecates `BidirectionalIterator`. |
| |
| #### `dart:core` |
| |
| - Allow omitting the `unencodedPath` positional argument to `Uri.http` and |
| `Uri.https` to default to an empty path. |
| |
| #### `dart:html` |
| |
| - Add `connectionState` attribute and `connectionstatechange` listener to |
| `RtcPeerConnection`. |
| |
| #### `dart:io` |
| |
| - **Breaking Change** [#49045](https://github.com/dart-lang/sdk/issues/49045): |
| The `uri` property of `RedirectException` in `dart:io` has been changed to |
| be nullable. Programs must be updated to handle the `null` case. |
| - **Breaking Change** [#34218](https://github.com/dart-lang/sdk/issues/34218): |
| Constants in `dart:io`'s networking APIs following the `SCREAMING_CAPS` |
| convention have been removed (they were previously deprecated). Please use |
| the corresponding `lowerCamelCase` constants instead. |
| |
| - **Breaking Change** [#45630][]: The Dart VM no longer automatically restores |
| the initial terminal settings upon exit. Programs that change the `Stdin` |
| settings `lineMode` and `echoMode` are now responsible for restoring the |
| settings upon program exit. E.g. a program disabling `echoMode` will now |
| need to restore the setting itself and handle exiting by the appropriate |
| signals if desired: |
| |
| ```dart |
| import 'dart:io'; |
| import 'dart:async'; |
| |
| main() { |
| bool echoWasEnabled = stdin.echoMode; |
| try { |
| late StreamSubscription subscription; |
| subscription = ProcessSignal.sigint.watch().listen((ProcessSignal signal) { |
| stdin.echoMode = echoWasEnabled; |
| subscription.cancel(); |
| Process.killPid(pid, signal); /* Die by the signal. */ |
| }); |
| stdin.echoMode = false; |
| } finally { |
| stdin.echoMode = echoWasEnabled; |
| } |
| } |
| ``` |
| |
| This change is needed to fix [#36453][] where the dart programs not caring |
| about the terminal settings can inadvertently corrupt the terminal settings |
| when e.g. piping into less. |
| |
| Furthermore the `echoMode` setting now only controls the `echo` local mode |
| and no longer sets the `echonl` local mode on POSIX systems (which controls |
| whether newline are echoed even if the regular echo mode is disabled). The |
| `echonl` local mode is usually turned off in common shell environments. |
| Programs that wish to control the `echonl` local mode can use the new |
| `echoNewlineMode` setting. |
| |
| The Windows console code pages (if not UTF-8) and ANSI escape code support |
| (if disabled) remain restored when the VM exits. |
| |
| [#45630]: https://github.com/dart-lang/sdk/issues/45630 |
| [#36453]: https://github.com/dart-lang/sdk/issues/36453 |
| |
| #### `dart:js_util` |
| |
| - Added `dartify` and a number of minor helper functions. |
| |
| ### Dart VM |
| |
| Implementation of `async`/`async*`/`sync*` is revamped in Dart VM, |
| both in JIT and AOT modes. This also affects Flutter except Flutter Web. |
| |
| Besides smaller code size and better performance of async methods, |
| the new implementation carries a few subtle changes in behavior: |
| |
| - If `async` method returns before reaching the first `await`, it now |
| returns a completed Future. |
| Previously `async` methods completed resulting Future in separate microtasks. |
| |
| - Stack traces no longer have duplicate entries for `async` methods. |
| |
| - New implementation now correctly throws an error if `null` occurs as |
| an argument of a logical expression (`&&` and `||`) which also contains |
| an `await`. |
| |
| - New implementation avoids unnecessary extending the liveness of local |
| variables in `async`/`async*`/`sync*` methods, which means that unused |
| objects stored in local variables in such methods might be garbage |
| collected earlier than they were before |
| (see issue [#36983](https://github.com/dart-lang/sdk/issues/36983) |
| for details). |
| |
| ### Tools |
| |
| #### General |
| |
| - **Breaking Change** [#48272](https://github.com/dart-lang/sdk/issues/48272): |
| The `.packages` file has been fully discontinued. Historically when the |
| commands `dart pub get` or `flutter pub get` are executed, pub resolved all |
| dependencies, and installs those dependencies to the local pub cache. It |
| furthermore created a mapping from each used package to their location on the |
| local file system, and wrote that into two files: |
| |
| * `.dart_tool/package_config.json` |
| * `.packages` (deprecated in Dart 2.8.0) |
| |
| As of Dart 2.18.0, the `.packages` is now fully desupported, and all tools |
| distributed in, and based on, the Dart SDK no longer support it, and thus |
| solely use the `.dart_tool/package_config.json` file. If you've run `dart pub |
| get` or `flutter pub get` with any Dart SDK from the past few years you |
| already have a `.dart_tool/package_config.json` and thus should not be |
| impacted. You can delete any old `.packages` files. |
| |
| If you have any third-party tools that for historical reasons depend on a |
| `.packages` we will support the ability to generate a `.packages` by passing |
| the flag `--legacy-packages-file` to `dart pub get`. This support will be |
| removed in a following stable release. |
| |
| #### Dart command line |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dart2js` and `dartdevc` tools have been removed as previously |
| announced. `dart2js` is replaced by the `dart compile js` command, `dartdevc` |
| is no longer exposed as a command-line tool. |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dartanalyzer` tool has been removed as previously |
| announced. `dartanalyzer` is replaced by the `dart analyze` command. |
| |
| #### Analyzer |
| |
| - added quick fixes for diagnostics: `abstract_field_constructor_initializer`, |
| `abstract_class_member`, |
| [`always_put_control_body_on_new_line`](https://dart.dev/lints/always_put_control_body_on_new_line), |
| [`avoid_print`](https://dart.dev/lints/avoid_print), |
| [`avoid_renaming_method_parameters`](https://dart.dev/lints/avoid_renaming_method_parameters), |
| [`discarded_futures`](https://dart.dev/lints/discarded_futures), |
| `enum_with_abstract_member`, `non_bool_condition`, |
| `super_formal_parameter_without_associated_named`, |
| [`unawaited_futures`](https://dart.dev/lints/unawaited_futures), |
| `unnecessary_final` `unused_element_parameter`, |
| - added new Hint: `deprecated_export_use` |
| |
| #### Linter |
| |
| Updated the Linter to `1.25.0`, which includes changes that |
| |
| - add new lint: `discarded_futures`. |
| - add new lint: `unnecessary_null_aware_operator_on_extension_on_nullable`. |
| - add new lint: `unnecessary_to_list_in_spreads`. |
| - improve message and highlight range for `no_duplicate_case_values` |
| - improve performance for `lines_longer_than_80_chars`, |
| `prefer_const_constructors_in_immutables`, and |
| `prefer_initializing_formals`. |
| - fix `prefer_final_parameters` to support super parameters. |
| - fix `unawaited_futures` to handle string interpolated |
| futures. |
| - update `use_colored_box` to not flag nullable colors, |
| - fix `no_leading_underscores_for_local_identifiers` |
| to lint local function declarations. |
| - fix `avoid_init_to_null` to correctly handle super |
| initializing defaults that are non-null. |
| - update `no_leading_underscores_for_local_identifiers` |
| to allow identifiers with just underscores. |
| - fix `flutter_style_todos` to support usernames that |
| start with a digit. |
| - update `require_trailing_commas` to handle functions |
| in asserts and multi-line strings. |
| - update `unsafe_html` to allow assignments to |
| `img.src`. |
| - fix `unnecessary_null_checks` to properly handle map |
| literal entries. |
| |
| #### Pub |
| |
| * `dart pub get` and `dart pub upgrade` no longer create the |
| `.packages` file. For details, see breaking change #48272 above. |
| * `dart pub outdated` now shows which of your dependencies are discontinued. |
| * `dart pub publish` will now list all the files it is about to publish. |
| |
| ## 2.17.7 - 2022-08-24 |
| |
| This is a patch release that: |
| |
| - fixes a crash in the debugger (issue [#49209][]). |
| |
| [#49209]: https://github.com/dart-lang/sdk/issues/49209 |
| |
| ## 2.17.6 - 2022-07-13 |
| |
| This is a patch release that: |
| |
| - improves code completion for Flutter (issue [#49054][]). |
| - fixes a crash on ARM (issue [#106510][]). |
| - fixes a compiler crash with Finalizable parameters (issue [#49402][]). |
| |
| [#49054]: https://github.com/dart-lang/sdk/issues/49054 |
| [#106510]: https://github.com/flutter/flutter/issues/106510 |
| [#49402]: https://github.com/dart-lang/sdk/issues/49402 |
| |
| ## 2.17.5 - 2022-06-22 |
| |
| This is a patch release that: |
| |
| - improves analysis of enums and switch (issue [#49188][]). |
| - fixes a compiler crash when initializing Finalizable objects |
| (issue [#49075][]). |
| |
| [#49188]: https://github.com/dart-lang/sdk/issues/49188 |
| [#49075]: https://github.com/dart-lang/sdk/issues/49075 |
| |
| ## 2.17.3 - 2022-06-01 |
| |
| This is a patch release that fixes: |
| |
| - a Dart VM compiler crash (issue [#100375][]). |
| - code completion when writing method overrides (issue [#49027][]). |
| - the `dart pub login` command (issue [#3424][]). |
| - analysis of enhanced enums (issue [#49097][]). |
| |
| [#100375]: https://github.com/flutter/flutter/issues/100375 |
| [#49027]: https://github.com/dart-lang/sdk/issues/49027 |
| [#3424]: https://github.com/dart-lang/pub/issues/3424 |
| [#49097]: https://github.com/dart-lang/sdk/issues/49097 |
| |
| ## 2.17.1 - 2022-05-18 |
| |
| This is a patch release that fixes: |
| |
| - an analyzer plugin crash (issue [#48682][]). |
| - Dart FFI support for `late` `Finalizable` variables (issue [#49024]). |
| - `dart compile` on macOS 10.15 (issue [#49010][]). |
| |
| [#48682]: https://github.com/dart-lang/sdk/issues/48682 |
| [#49024]: https://github.com/dart-lang/sdk/issues/49024 |
| [#49010]: https://github.com/dart-lang/sdk/issues/49010 |
| |
| ## 2.17.0 - 2022-05-11 |
| |
| ### Language |
| |
| The following features are new in the Dart 2.17 [language version][]. To use |
| them, you must set the lower bound on the SDK constraint for your package to |
| 2.17 or greater (`sdk: '>=2.17.0 <3.0.0'`). |
| |
| [language version]: https://dart.dev/guides/language/evolution |
| |
| - **[Enhanced enums with members][]**: Enum declarations can now define |
| members including fields, constructors, methods, getters, etc. For example: |
| |
| ```dart |
| enum Water { |
| frozen(32), |
| lukewarm(100), |
| boiling(212); |
| |
| final int tempInFahrenheit; |
| const Water(this.tempInFahrenheit); |
| |
| @override |
| String toString() => "The $name water is $tempInFahrenheit F."; |
| } |
| ``` |
| |
| Constructors must be `const` since enum values are always constants. If the |
| constructor takes arguments, they are passed when the enum value is |
| declared. |
| |
| The above enum can be used like so: |
| |
| ```dart |
| void main() { |
| print(Water.frozen); // prints "The frozen water is 32 F." |
| } |
| ``` |
| |
| [enhanced enums with members]: https://github.com/dart-lang/language/blob/master/accepted/future-releases/enhanced-enums/feature-specification.md |
| |
| - **[Super parameters][]**: When extending a class whose constructor takes |
| parameters, the subclass constructor needs to provide arguments for them. |
| Often, these are passed as parameters to the subclass constructor, which |
| then forwards them to the superclass constructor. This is verbose because |
| the subclass constructor must list the name and type of each parameter in |
| its parameter list, and then explicitly forward each one as an argument to |
| the superclass constructor. |
| |
| [@roy-sianez][] suggested [allowing `super.`][super dot] before a subclass |
| constructor parameter to implicitly forward it to the corresponding |
| superclass constructor parameter. Applying this feature to Flutter |
| eliminated [nearly 2,000 lines of code][flutter super]. For example, before: |
| |
| ```dart |
| class CupertinoPage<T> extends Page<T> { |
| const CupertinoPage({ |
| required this.child, |
| this.maintainState = true, |
| this.title, |
| this.fullscreenDialog = false, |
| LocalKey? key, |
| String? name, |
| Object? arguments, |
| String? restorationId, |
| }) : super( |
| key: key, |
| name: name, |
| arguments: arguments, |
| restorationId: restorationId, |
| ); |
| |
| // ... |
| } |
| ``` |
| |
| And using super parameters: |
| |
| ```dart |
| class CupertinoPage<T> extends Page<T> { |
| const CupertinoPage({ |
| required this.child, |
| this.maintainState = true, |
| this.title, |
| this.fullscreenDialog = false, |
| super.key, |
| super.name, |
| super.arguments, |
| super.restorationId, |
| }); |
| |
| // ... |
| } |
| ``` |
| |
| From our analysis, over 90% of explicit superclass constructor calls can be |
| completely eliminated, using `super.` parameters instead. |
| |
| [super parameters]: https://github.com/dart-lang/language/blob/master/working/1855%20-%20super%20parameters/proposal.md |
| [@roy-sianez]: https://github.com/roy-sianez |
| [super dot]: https://github.com/dart-lang/language/issues/1855 |
| [flutter super]: https://github.com/flutter/flutter/pull/100905/files |
| |
| - **[Named args everywhere][]**: In a function call, Dart requires positional |
| arguments to appear before named arguments. This can be frustrating for |
| arguments like collection literals and function expressions that look best |
| as the last argument in the argument list but are positional, like the |
| `test()` function in the [test package][]: |
| |
| ```dart |
| main() { |
| test('A test description', () { |
| // Very long function body here... |
| }, skip: true); |
| } |
| ``` |
| |
| It would be better if the `skip` argument appeared at the top of the call |
| to `test()` so that it wasn't easily overlooked, but since it's named and |
| the test body argument is positional, `skip` must be placed at the end. |
| |
| Dart 2.17 removes this restriction. Named arguments can be freely |
| interleaved with positional arguments, allowing code like: |
| |
| ```dart |
| main() { |
| test(skip: true, 'A test description', () { |
| // Very long function body here... |
| }); |
| } |
| ``` |
| |
| [named args everywhere]: https://github.com/dart-lang/language/blob/master/accepted/future-releases/named-arguments-anywhere/feature-specification.md |
| [test package]: https://pub.dev/packages/test |
| |
| ### Core libraries |
| |
| #### `dart:core` |
| |
| - Add `Finalizer` and `WeakReference` which can potentially detect when |
| objects are "garbage collected". |
| - Add `isMimeType` method to `UriData` class, to allow case-insensitive |
| checking of the MIME type. |
| - Add `isCharset` and `isEncoding` methods to `UriData` class, |
| to allow case-insensitive and alternative-encoding-name aware checking |
| of the MIME type "charset" parameter. |
| - Make `UriData.fromString` and `UriData.fromBytes` recognize and omit |
| a "text/plain" `mimeType` even if it is not all lower-case. |
| |
| #### `dart:ffi` |
| |
| - Add `ref=` and `[]=` methods to the `StructPointer` and `UnionPointer` |
| extensions. They copy a compound instance into a native memory region. |
| - Add `AbiSpecificInteger`s for common C types: |
| - `char` |
| - `unsigned char` |
| - `signed char` |
| - `short` |
| - `unsigned short` |
| - `int` |
| - `unsigned int` |
| - `long` |
| - `unsigned long` |
| - `long long` |
| - `unsigned long long` |
| - `uintptr_t` |
| - `size_t` |
| - `wchar_t` |
| - Add `NativeFinalizer` which can potentially detect when objects are |
| "garbage collected". `NativeFinalizer`s run native code where `dart:core`'s |
| `Finalizer`s run Dart code on finalization. |
| |
| #### `dart:html` |
| |
| - Add `scrollIntoViewIfNeeded` to `Element`. Previously, this method was nested |
| within `scrollIntoView` based on the `ScrollAlignment` value. `scrollIntoView` |
| is unchanged for now, but users who intend to use the native |
| `Element.scrollIntoViewIfNeeded` should use the new `scrollIntoViewIfNeeded` |
| definition instead. |
| - Change `Performance.mark` and `Performance.measure` to accept their different |
| overloads. `mark` can now accept a `markOptions` map, and `measure` can now |
| accept a `startMark` and `endMark`, or a `measureOptions` map. Both methods |
| return their correct return types now as well - `PerformanceEntry?` and |
| `PerformanceMeasure?`, respectively. |
| |
| #### `dart:indexed_db` |
| |
| - `IdbFactory.supportsDatabaseNames` has been deprecated. It will always return |
| `false`. |
| |
| #### `dart:io` |
| |
| - **Breaking Change** [#47887](https://github.com/dart-lang/sdk/issues/47887): |
| `HttpClient` has a new `connectionFactory` property, which allows socket |
| creation to be customized. Classes that `implement HttpClient` may be broken |
| by this change. Add the following method to your classes to fix them: |
| |
| ```dart |
| void set connectionFactory( |
| Future<ConnectionTask<Socket>> Function( |
| Uri url, String? proxyHost, int? proxyPort)? |
| f) => |
| throw UnsupportedError("connectionFactory not implemented"); |
| ``` |
| |
| - **Breaking Change** [#48093](https://github.com/dart-lang/sdk/issues/48093): |
| `HttpClient` has a new `keyLog` property, which allows TLS keys to be logged |
| for debugging purposes. Classes that `implement HttpClient` may be broken by |
| this change. Add the following method to your classes to fix them: |
| |
| ```dart |
| void set keyLog(Function(String line)? callback) => |
| throw UnsupportedError("keyLog not implemented"); |
| ``` |
| |
| - **Breaking Change** [#34218](https://github.com/dart-lang/sdk/issues/34218): |
| Constants in `dart:io` following the `SCREAMING_CAPS` convention have been |
| removed (they were previously deprecated). Please use the corresponding |
| `lowerCamelCase` constants instead. |
| - **Breaking Change** [#48513](https://github.com/dart-lang/sdk/issues/48513): |
| Add a new `allowLegacyUnsafeRenegotiation` property to `SecurityContext`, |
| which allows TLS renegotiation for client secure sockets. |
| - Add a optional `keyLog` parameter to `SecureSocket.connect` and |
| `SecureSocket.startConnect`. |
| - Deprecate `SecureSocket.renegotiate` and `RawSecureSocket.renegotiate`, |
| which were no-ops. |
| |
| ### Tools |
| |
| #### Dart command line |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dart2js` tool has been |
| marked deprecated as previously announced. |
| Its replacement is the `dart compile js` command. |
| Should you find any issues, or missing features, in the replacement |
| command, kindly file [an issue](https://github.com/dart-lang/sdk/issues/new). |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dartdevc` tool has been marked deprecated as previously |
| announced and will be deleted in a future Dart stable release. This tool |
| was intended for use only by build systems like bazel, `build_web_compilers` |
| and `flutter_tools`. The functionality remains available for those systems, |
| but it is no longer exposed as a command-line tool in the SDK. |
| Please share any concerns in the |
| [breaking change tracking issue](https://github.com/dart-lang/sdk/issues/46100). |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dartdoc` tool has been removed as |
| previously announced. Its replacement is the `dart doc` command. |
| |
| - The template names used in the `dart create` command have been simplified, |
| and the current template names are now the set shown below. (Note: for |
| backwards compatibility the former template names can still be used.) |
| ``` |
| [console] (default) A command-line application. |
| [package] A package containing shared Dart libraries. |
| [server-shelf] A server app using package:shelf. |
| [web] A web app that uses only core Dart libraries. |
| ``` |
| |
| #### Analyzer |
| |
| - added quick fixes for diagnostics: |
| [`always_use_package_imports`](https://dart.dev/lints/always_use_package_imports), |
| [`avoid_void_async`](https://dart.dev/lints/avoid_void_async), |
| [`cascade_invocations`](https://dart.dev/lints/cascade_invocations), |
| `default_list_constructor`, |
| [`must_call_super`](https://dart.dev/tools/diagnostic-messages#must_call_super), |
| [`no_leading_underscores_for_local_identifiers`](https://dart.dev/lints/no_leading_underscores_for_local_identifiers), |
| [`null_check_on_nullable_type_parameter`](https://dart.dev/lints/null_check_on_nullable_type_parameter), |
| [`prefer_function_declarations_over_variables`](https://dart.dev/lints/prefer_function_declarations_over_variables), |
| [`sort_constructors_first`](https://dart.dev/lints/sort_constructors_first), |
| [`sort_unnamed_constructors_first`](https://dart.dev/lints/sort_unnamed_constructors_first), |
| `undefined_enum_constant`, |
| [`unnecessary_late`](https://dart.dev/lints/unnecessary_late), |
| `unnecessary_null_aware_assignments`, |
| [`use_enums`](https://dart.dev/lints/use_enums), |
| [`use_raw_strings`](https://dart.dev/lints/use_raw_strings), |
| [`use_super_parameters`](https://dart.dev/lints/use_super_parameters), |
| `var_return_type` |
| - added many errors for invalid enhanced enums |
| - added new Hint: [`unnecessary_final`](https://dart.dev/tools/diagnostic-messages#unnecessary_final) |
| - added new FFI error: `compound_implements_finalizable` |
| - improved errors for invalid Unicode escapes in source code |
| |
| #### Linter |
| |
| Updated the Linter to `1.22.0`, which includes changes that |
| |
| - fixes null-safe variance exceptions in `invariant_booleans`. |
| - updates `depend_on_referenced_packages` to treat `flutter_gen` as a virtual |
| package, not needing an explicit dependency. |
| - updates `unnecessary_null_checks` and |
| `null_check_on_nullable_type_parameter` to handle |
| list/set/map literals, and `yield` and `await` expressions. |
| - fixes `unnecessary_null_aware_assignments` property-access |
| false positives. |
| - adds new lint: `use_super_parameters`. |
| - adds new lint: `use_enums`. |
| - adds new lint: `use_colored_box`. |
| - improves performance for `sort_constructors`. |
| - improves docs for `always_use_package_imports`, |
| `avoid_print`, and `avoid_relative_lib_imports` . |
| - updates `avoid_void_async` to skip `main` functions. |
| - updates `prefer_final_parameters` to not super on super params. |
| - updates lints for enhanced-enums and super-initializer language |
| features. |
| - updates `unnecessary_late` to report on variable names. |
| - marks `null_check_on_nullable_type_parameter` stable. |
| |
| #### Dartdoc |
| |
| Updated dartdoc to 5.1.0, which includes changes that |
| |
| - support the enhanced enums feature |
| - remove superfluous `[...]` links |
| - fix `categoryOrder` option |
| - display categorized extensions |
| - add annotations to extensions |
| - make minor improvements to performance |
| |
| ## 2.16.2 - 2022-03-24 |
| |
| This is a patch release that fixes a dart2js crash when building some Flutter |
| web apps (issue [#47916][]). |
| |
| [#47916]: https://github.com/dart-lang/sdk/issues/47916 |
| |
| ## 2.16.1 - 2022-02-09 |
| |
| This is a patch release that fixes an AOT precompiler crash when building some |
| Flutter apps (issue [flutter/flutter#97301][]). |
| |
| [flutter/flutter#97301]: https://github.com/flutter/flutter/issues/97301 |
| |
| ## 2.16.0 - 2022-02-03 |
| |
| ### Core libraries |
| |
| #### `dart:core` |
| |
| - Add `Error.throwWithStackTrace` which can `throw` an |
| error with an existing stack trace, instead of creating |
| a new stack trace. |
| |
| #### `dart:ffi` |
| |
| - Add `Abi` and `AbiSpecificInteger`. These enable specifying integers which |
| have different sizes/signs per ABI (hardware and OS combination). |
| |
| #### `dart:io` |
| |
| - **Security advisory** |
| [CVE-2022-0451](https://github.com/dart-lang/sdk/security/advisories/GHSA-c8mh-jj22-xg5h), |
| **breaking change** [#45410](https://github.com/dart-lang/sdk/issues/45410): |
| `HttpClient` no longer transmits some headers (i.e. `authorization`, |
| `www-authenticate`, `cookie`, `cookie2`) when processing redirects to a |
| different domain. |
| - **Breaking change** [#47653](https://github.com/dart-lang/sdk/issues/47653): |
| On Windows, `Directory.rename` will no longer delete a directory if |
| `newPath` specifies one. Instead, a `FileSystemException` will be thrown. |
| - **Breaking change** [#47769](https://github.com/dart-lang/sdk/issues/47769): |
| The `Platform.packageRoot` API has been removed. It had been marked deprecated |
| in 2018, as it doesn't work with any Dart 2.x release. |
| - Add optional `sourcePort` parameter to `Socket.connect`, `Socket.startConnect`, `RawSocket.connect` and `RawSocket.startConnect` |
| |
| #### `dart:isolate` |
| |
| - **Breaking change** [#47769](https://github.com/dart-lang/sdk/issues/47769): |
| The `Isolate.packageRoot` API has been removed. It had been marked deprecated |
| in 2018, as it doesn't work with any Dart 2.x release. |
| |
| ### Tools |
| |
| #### Dart command line |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dartanalyzer` tool has been |
| marked deprecated as previously announced. |
| Its replacement is the `dart analyze` command. |
| Should you find any issues, or missing features, in the replacement |
| command, kindly file [an issue][]. |
| |
| [an issue]: https://github.com/dart-lang/sdk/issues/new |
| |
| - **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The standalone `dartdoc` tool has been |
| marked deprecated as previously announced. |
| Its replacement is the `dart doc` command. |
| Should you find any issues, or missing features, in the replacement |
| command, kindly file [an issue][]. |
| |
| [an issue]: https://github.com/dart-lang/sdk/issues/new |
| |
| - **Breaking Change** [#46100](https://github.com/dart-lang/sdk/issues/46100): |
| The deprecated standalone `pub` tool has been removed. |
| Its replacement is the `dart pub` command. |
| Should you find any issues, or missing features, in the replacement |
| command, kindly file [an issue][]. |
| |
| [an issue]: https://github.com/dart-lang/pub/issues/new |
| |
| #### Pub |
| |
| - Fixed race conditions in `dart pub get`, `dart run` and `dart pub global run`. |
| It should now be safe to run these concurrently. |
| - If (when) Pub crashes it will save a verbose log in |
| `$PUB_CACHE/log/pub_log.txt` This can be used for filing issues to the issue |
| tracker. |
| |
| `dart --verbose pub [command]` will also cause the log file to be written. |
| - `dart pub global activate --source=git` now takes arguments `--git-path` to |
| specify the path of the activated package in the pubspec and `--git-ref` to |
| specify the branch or revision to check out. |
| - `dart pub add` can now add multiple packages in one command. |
| - `dart pub token add` can now add a token for [pub.dev](https://pub.dev). |
| - `dart pub uploader` has been removed. To manage uploaders for a package use |
| the `https://pub.dev/<packagename>/admin` web-interface. |
| - Pub now supports a separate `pubspec_overrides.yaml` file that can contain |
| `dependency_overrides`. This makes it easier to avoid checking the local |
| overrides into version control. |
| |
| #### Linter |
| |
| Updated the Linter to `1.18.0`, which includes changes that |
| |
| - extends `camel_case_types` to cover enums. |
| - fixes `no_leading_underscores_for_local_identifiers` to not |
| mis-flag field formal parameters with default values. |
| - fixes `prefer_function_declarations_over_variables` to not |
| mis-flag non-final fields. |
| - improves performance for `prefer_contains`. |
| - updates `exhaustive_cases` to skip deprecated values that |
| redirect to other values. |
| - adds new lint: `unnecessary_late`. |
| - improves docs for `prefer_initializing_formals`. |
| - updates `secure_pubspec_urls` to check `issue_tracker` and |
| `repository` entries. |
| - adds new lint: `conditional_uri_does_not_exist`. |
| - improves performance for |
| `missing_whitespace_between_adjacent_strings`. |
| - adds new lint: `avoid_final_parameters`. |
| - adds new lint: `no_leading_underscores_for_library_prefixes`. |
| - adds new lint: `no_leading_underscores_for_local_identifiers`. |
| - adds new lint: `secure_pubspec_urls`. |
| - adds new lint: `sized_box_shrink_expand`. |
| - adds new lint: `use_decorated_box`. |
| - improves docs for `omit_local_variable_types`. |
| |
| ## 2.15.1 - 2021-12-14 |
| |
| This is a patch release that fixes: |
| |
| - an AOT compilation failure in some Flutter apps (issue [#47878][]). |
| - `dart pub publish` for servers with a path in the URL (pr |
| [dart-lang/pub#3244][]). |
| |
| [#47878]: https://github.com/dart-lang/sdk/issues/47878 |
| [dart-lang/pub#3244]: https://github.com/dart-lang/pub/pull/3244 |
| |
| ## 2.15.0 - 2021-12-08 |
| |
| - **Security advisory** |
| [CVE-2021-22567](https://github.com/dart-lang/sdk/security/advisories/GHSA-8pcp-6qc9-rqmv): |
| Bidirectional Unicode text can be interpreted and compiled differently than |
| how it appears in editors and code-review tools. Exploiting this an attacker |
| could embed source that is invisible to a code reviewer but that modifies the |
| behavior of a program in unexpected ways. Dart 2.15.0 introduces new analysis |
| warnings that flags the use of these. |
| |
| - **Security advisory** |
| [CVE-2021-22568](https://github.com/dart-lang/sdk/security/advisories/GHSA-r32f-vhjp-qhj7): |
| A malicious third-party package repository may impersonate a user on pub.dev |
| for up to one hour after the user has published a package to that third-party |
| package repository using `dart pub publish`. As of Dart SDK version 2.15.0 |
| requests to third-party package repositories will no longer include an OAuth2 |
| `access_token` intended for pub.dev. |
| |
| ### Language |
| |
| The following features are new in the Dart 2.15 [language version][]. To use |
| them, you must set the lower bound on the SDK constraint for your package to |
| 2.15 or greater (`sdk: '>=2.15.0 <3.0.0'`). |
| |
| [language version]: https://dart.dev/guides/language/evolution |
| |
| - **[Constructor tear-offs][]**: Previous Dart versions allowed a method on an |
| instance to be passed as a closure, and similarly for static methods. This is |
| commonly referred to as "closurizing" or "tearing off" a method. Constructors |
| were not previously eligible for closurization, forcing users to explicitly |
| write wrapper functions when using constructors as first class functions. |
| See the calls to `map()` in this example: |
| |
| ```dart |
| class A { |
| int x; |
| A(this.x); |
| A.fromString(String s) : x = int.parse(s); |
| } |
| |
| void main() { |
| var listOfInts = [1, 2, 3]; |
| var listOfStrings = ["1", "2", "3"]; |
| for(var a in listOfInts.map((x) => A(x))) { |
| print(a.x); |
| } |
| for(var a in listOfStrings.map((x) => A.fromString(x))) { |
| print(a.x); |
| } |
| } |
| ``` |
| |
| New in Dart 2.15, constructors are now allowed to be torn off. Named |
| constructors are closurized using their declared name (here `A.fromString`). |
| To closurize unnamed constructors, use the keyword `new` (here `A.new`). |
| The above example may now be written as: |
| |
| ```dart |
| class A { |
| int x; |
| A(this.x); |
| A.fromString(String s) : x = int.parse(s); |
| } |
| |
| void main() { |
| var listOfInts = [1, 2, 3]; |
| var listOfStrings = ["1", "2", "3"]; |
| for(A a in listOfInts.map(A.new)) { |
| print(a.x); |
| } |
| for(A a in listOfStrings.map(A.fromString)) { |
| print(a.x); |
| } |
| } |
| ``` |
| |
| Constructors for generic classes may be torn off as generic functions, or |
| instantiated at the tear-off site. In the following example, the tear-off |
| `G.new` is used to initialize the variable `f` produces a generic function |
| which may be used to produce an instance of `G<T>` for any type `T` provided |
| when `f` is called. The tear-off `G<String>.new` is used to initialize the |
| variable `g` to produce a non-generic function which may only be used |
| to produce instances of type `G<String>`. |
| |
| ```dart |
| class G<T> { |
| T x; |
| G(this.x); |
| } |
| |
| void main() { |
| G<T> Function<T>(T x) f = G.new; |
| var x = f<int>(3); |
| G<String> Function(String y) g = G<String>.new; |
| var y = g("hello"); |
| } |
| ``` |
| |
| [constructor tear-offs]: https://github.com/dart-lang/language/blob/master/accepted/2.15/constructor-tearoffs/feature-specification.md |
| |
| - **[Generic type literals][explicit instantiation]**: Previous Dart versions |
| allowed class names to be used as type literals. So for example,`int` may be |
| used as an expression, producing a value of type `Type`. Generic classes (e.g. |
| `List`) could be referred to by name as an expression, but no type arguments |
| could be provided and so only the `dynamic` instantiation could be produced |
| directly as an expression without using indirect methods: |
| |
| ```dart |
| // Workaround to capture generic type literals. |
| Type typeOf<T>() => T; |
| |
| void main() { |
| var x = int; // The Type literal corresponding to `int`. |
| var y = List; // The Type literal corresponding to `List<dynamic>`. |
| // Use workaround to capture generic type literal. |
| var z = typeOf<List<int>>(); // The Type literal for `List<int>`. |
| } |
| ``` |
| |
| New in Dart 2.15, instantiations of generic classes may now be used as Type |
| literals: |
| |
| ```dart |
| void main() { |
| var x = int; // The Type literal corresponding to `int`. |
| var y = List; // The Type literal corresponding to `List<dynamic>`. |
| var z = List<int>; // The Type literal corresponding to `List<int>`. |
| } |
| ``` |
| |
| - **[Explicit generic method instantiations][explicit instantiation]**: Previous |
| Dart versions allowed generic methods to be implicitly specialized (or |
| "instantiated") to non-generic versions when assigned to a location with a |
| compatible monomorphic type. Example: |
| |
| ```dart |
| // The generic identity function. |
| T id<T>(T x) => x; |
| |
| void main() { |
| // Initialize `intId` with a version of `id` implicitly specialized to |
| // `int`. |
| int Function(int) intId = id; |
| print(intId(3)); |
| // Initialize `stringId` with a version of `id` implicitly specialized to |
| // `String`. |
| String Function(String) stringId = id; |
| print(stringId("hello")); |
| } |
| ``` |
| |
| New in Dart 2.15, generic methods may be explicitly instantiated using the |
| syntax `f<T>` where `f` is the generic method to specialize and `T` is the |
| type argument (in general, type arguments) to be used to specialize the |
| method. Example: |
| |
| ```dart |
| // The generic identity function. |
| T id<T>(T x) => x; |
| |
| void main() { |
| // Initialize `intId` with a version of `id` explicitly specialized to |
| // `int`. |
| var intId = id<int>; |
| print(intId(3)); |
| // Initialize `stringId` with a version of `id` explicitly specialized to |
| // `String`. |
| var stringId = id<String>; |
| print(stringId("hello")); |
| } |
| ``` |
| |
| [explicit instantiation]: https://github.com/dart-lang/language/blob/master/accepted/2.15/constructor-tearoffs/feature-specification.md#explicitly-instantiated-classes-and-functions |
| |
| - **[Generic instantiation of function objects][object instantiation]**: Generic |
| function instantiation was previously restricted to function declarations. For |
| example, as soon as a function had been torn off, it could not be |
| instantiated: |
| |
| ```dart |
| // Before Dart 2.15: |
| X id<X>(X x) => x; |
| |
| void main() { |
| var fo = id; // Tear off `id`, creating a function object. |
| var c1 = fo<int>; // Compile-time error: can't instantiate `fo`. |
| int Function(int) c2 = fo; // Same compile-time error. |
| // Constants are treated the same. |
| } |
| ``` |
| |
| New in Dart 2.15, this restriction has been lifted. It is now possible |
| to obtain a generic instantiation of an existing function object, both |
| explicitly and implicitly (again, this works the same for non-constants): |
| |
| ```dart |
| X id<X>(X x) => x; |
| X other<X>(X x) => throw x; |
| |
| void main() { |
| const fo = id; // Tear off `id`, creating a function object. |
| |
| // Generic function instantiation on `fo` is no longer an error. |
| const c1 = fo<int>; // OK. |
| const int Function(int) c2 = fo; // OK. |
| |
| // This also generalizes function instantiation because we can, |
| // e.g., use non-trivial expressions and go via a constructor. |
| const c3 = A(true); // OK. |
| } |
| |
| class A { |
| final int Function(int) x; |
| // `(...)<T>` is now allowed, also in a `const` constructor. |
| const A(bool b): x = (b ? id : other)<int>; |
| } |
| ``` |
| |
| [Object instantiation]: https://github.com/dart-lang/language/pull/1812 |
| |
| - Annotations on type parameters of classes can no longer refer to class members |
| without a prefix. For example, this used to be permitted: |
| |
| ```dart |
| class C<@Annotation(foo) T> { |
| static void foo() {} |
| } |
| ``` |
| |
| Now, the reference must be qualified with the class name, i.e.: |
| |
| ```dart |
| class C<@Annotation(C.foo) T> { |
| static void foo() {} |
| } |
| ``` |
| |
| This brings the implementation behavior in line with the spec. |
| |
| - Initializer expressions on implicitly typed condition variables can now |
| contribute to type promotion. For example, this program no longer produces a |
| compile-time error: |
| |
| ```dart |
| f(int? i) { |
| var iIsNull = i == null; |
| if (!iIsNull) { |
| print(i + 1); // OK, because `i` is known to be non-null. |
| } |
| } |
| ``` |
| |
| Previously, the above program had a compile-time error due to a bug |
| ([#1785][]) in type promotion which prevented the initializer expression |
| (`i == null`) from being accounted for when the variable in question |
| (`iIsNull`) lacked an explicit type. |
| |
| To avoid causing problems for packages that are intended to work with older |
| versions of Dart, the fix only takes effect when the minimum SDK of the source |
| packages is 2.15 or greater. |
| |
| [#1785]: https://github.com/dart-lang/language/issues/1785 |
| |
| - Restrictions on members of a class with a constant constructor are relaxed |
| such that they only apply when the class has a _generative_ constant |
| constructor. For example, this used to be an error, but is now permitted: |
| |
| ```dart |
| abstract class A { |
| const factory A() = B; |
| var v1; |
| late final v2 = Random().nextInt(10); |
| late final v3; |
| } |
| |
| class B implements A { |
| const B([this.v3 = 1]); |
| get v1 => null; |
| set v1(_) => throw 'Cannot mutate B.v1'; |
| final v2 = 0; |
| final v3; |
| set v3(_) => throw 'Cannot initialize B.v3'; |
| } |
| ``` |
| |
| This implements a relaxation of the specified rule for a `late final` |
| instance variable, and it brings the implementation behavior in line with |
| the specification in all other cases. |
| |
| - **Function object canonicalization and equality**: Several corner cases in the |
| area of function object canonicalization and function object equality have |
| been updated, such that all tools behave in the same way, and the behavior |
| matches the specification. |
| |
| In particular, function objects are now equal when they are obtained by |
| generic instantiation from the same function with the same actual type |
| arguments, even when that type argument is not known at compile time. |
| When the expressions are constant then the function objects are identical. |
| Constant expressions are treated as such even when they do not occur in a |
| constant context (e.g., `var f = top;`). |
| |
| ### Core libraries |
| |
| #### `dart:async` |
| |
| - Make the `unawaited` function's argument nullable, to allow calls like |
| `unawaited(foo?.bar())`. |
| |
| #### `dart:cli` |
| |
| - The experimental `waitFor` functionality, and the library containing only that |
| function, are now deprecated. |
| |
| #### `dart:core` |
| |
| - Add extension `name` getter on enum values. |
| - Add `Enum.compareByIndex` helper function for comparing enum values by index. |
| - Add `Enum.compareByName` helper function for comparing enum values by name. |
| - Add extension methods on `Iterable<T extends Enum>`, intended for |
| `SomeEnumType.values` lists, to look up values by name. |
| - Deprecate `IntegerDivisionByZeroException`. |
| Makes the class also implement `Error`. Code throwing the exception will be |
| migrated to throwing an `Error` instead until the class is unused and |
| ready to be removed. |
| Code catching the class should move to catching `Error` instead |
| (or, for integers, check first for whether it's dividing by zero). |
| |
| #### `dart:ffi` |
| |
| - Add `Bool` native type. |
| |
| #### `dart:io` |
| |
| - **Breaking change** [#46875](https://github.com/dart-lang/sdk/issues/46875): |
| The `SecurityContext` class in `dart:io` has been updated to set the minimum |
| TLS protocol version to TLS1_2_VERSION (1.2) instead of TLS1_VERSION. |
| - Add `RawSocket.sendMessage`, `RawSocket.receiveMessage` that allow passing of |
| file handle references via Unix domain sockets. |
| |
| #### `dart:js_util` |
| |
| - The `js_util` methods `setProperty`, `callMethod`, and `callConstructor` have |
| been optimized to remove checks on arguments when the checks can be elided. |
| Also, those methods, along with `getProperty` and `newObject`, now support a |
| generic type argument to specify a return type. These two changes make simple |
| `js_util` usage, like reading and writing primitive properties or calling |
| methods with simple arguments, have zero overhead. |
| |
| #### `dart:web_sql` |
| |
| - **Breaking change** [#46316](https://github.com/dart-lang/sdk/issues/46316): |
| The WebSQL standard was abandoned more than 10 |
| years ago and is not supported by many browsers. This release completely |
| deletes the `dart:web_sql` library. |
| |
| #### `dart:html` |
| |
| - **Breaking change** [#46316](https://github.com/dart-lang/sdk/issues/46316): |
| Related to the removal of `dart:web_sql` (see above), `window.openDatabase` |
| has been removed. |
| |
| ### Tools |
| |
| #### Dart command line |
| |
| - **Breaking change** [#46100][]: The standalone `dart2native` tool has been |
| removed as previously announced. Its replacements are the |
| `dart compile exe` and `dart compile aot-snapshot` commands, which offer the |
| same functionality. |
| |
| - **Breaking change**: The standalone `dartfmt` tool has been removed as |
| previously announced. Its replacement is the `dart format` command. |
| |
| Note that `dart format` has [a different set of options and |
| defaults][dartfmt cli] than `dartfmt`. |
| |
| - When a script is `dart run` it will always be precompiled, but with |
| incremental precompilation for following runs. |
| |
| #### Dart VM |
| |
| - **Breaking change** [#45451](https://github.com/dart-lang/sdk/issues/45451): |
| Support for `dart-ext:`-style native extensions has been removed as previously |
| announced. Use `dart:ffi` to bind to native libraries instead. |
| |
| - **Breaking change** [#46754](https://github.com/dart-lang/sdk/issues/46754): |
| Isolates spawned via the `Isolate.spawn()` API are now grouped, operate on the |
| same managed heap and can therefore share various VM-internal data structures. |
| |
| This leads to ~100x faster isolate startup latency, ~10-100x lower |
| per-isolate base memory overhead and ~8x faster inter-isolate communication. |
| |
| Making isolates operate on the same heap will also make them collaborate on |
| garbage collections, which changes performance characteristics for GC-heavy |
| applications that may - in rare cases - negatively affect pause times or |
| throughput. |
| |
| - Allow closures both in inter-isolate messages as well as as entrypoints in |
| `Isolate.spawn(<entrypoint>, ...)` calls. Closures and their enclosing context |
| may need to be copied in this process. The enclosing context is - as with |
| normal messages - verified to only contain objects that are sendable. |
| |
| Note of caution: The Dart VM's current representation of enclosing variables |
| in closures can make closures hang on to more variables than strictly needed. |
| Using such closures in inter-isolate communication can therefore lead to |
| copying of larger transitive object graphs. If the extended transitive |
| closure includes objects that are illegal to send, the sending will fail. |
| See [#36983](https://github.com/dart-lang/sdk/issues/36983), which tracks this |
| existing memory leak issue. |
| |
| #### Linter |
| |
| Updated the Linter to `1.14.0`, which includes changes that |
| - improves performance for `annotate_overrides`, `prefer_contains`, and |
| `prefer_void_to_null`. |
| - marks `avoid_dynamic_calls` stable. |
| - fixed `avoid_null_checks_in_equality_operators` false positive with |
| non-nullable params. |
| - update `avoid_print` to allow `kDebugMode`-wrapped print calls. |
| - adds support for constructor tear-offs to `avoid_redundant_argument_values`, |
| `unnecessary_lambdas`, and `unnecessary_parenthesis`. |
| - improves messages for `avoid_renaming_method_parameters`. |
| - improves regular expression parsing performance for common checks |
| (`camel_case_types`, `file_names`, etc.). |
| - fixed `file_names` to report at the start of the file |
| (not the entire compilation unit). |
| - allow `while (true) { ... }` in `literal_only_boolean_expressions`. |
| - fixed `omit_local_variable_types` false positives. |
| - fixed `omit_local_variable_types` to not flag a local type that is required |
| for inference. |
| - fixed `overridden_fields` false positive with static fields. |
| - fixed `prefer_collection_literals` named typed parameter false positives. |
| - fixed `prefer_const_constructors` false positive for deferred imports. |
| - fixed `prefer_final_parameters` handling of initializing formals. |
| - fixed `prefer_generic_function_type_aliases` false positives with incomplete |
| statements. |
| - fixed `prefer_initializing_formals` false positives with factory constructors. |
| - fixed `prefer_void_to_null` false positive with overridden properties. |
| - fixed `prefer_void_to_null` false positives on overriding returns. |
| - fixed `prefer_void_to_null` false positives. |
| - adds a new lint: `unnecessary_constructor_name` to flag unnecessary uses of |
| `.new`. |
| - updates `unnecessary_getters_setters` to only flag the getter. |
| - fixed `unnecessary_parenthesis` false positive with function expressions. |
| - fixed `use_build_context_synchronously` false positive in awaits inside |
| anonymous functions. |
| - improve control flow analysis for `use_build_context_synchronously`. |
| - fixed `use_rethrow_when_possible` false positives. |
| - fixed `void_checks` false positives with incomplete source. |
| |
| ### Pub |
| |
| - If you have analytics enabled `dart pub get` will send |
| [usage metrics](https://github.com/dart-lang/pub/blob/0035a40f25d027130c0314571da53ffafc6d973b/lib/src/solver/result.dart#L131-L175) |
| for packages from pub.dev, intended for popularity analysis. |
| - Adds support for token-based authorization to third-party package-repositories |
| with the new command `dart pub token`. |
| - Credentials are no longer stored in the pub-cache, but in a platform dependent |
| config directory: |
| * On Linux `$XDG_CONFIG_HOME/dart/pub-credentials.json` if `$XDG_CONFIG_HOME` |
| is defined, otherwise `$HOME/.config/dart/pub-credentials.json` |
| * On Mac OS: `$HOME/Library/Application Support/dart/pub-credentials.json` |
| * On Windows: `%APPDATA%/dart/pub-credentials.json` |
| - The syntax for dependencies hosted at a third-party package repository has |
| been simplified. Before you would need to write: |
| |
| ```yaml |
| dependencies: |
| colorizer: |
| hosted: |
| name: colorizer |
| url: 'https://custom-pub-server.com' |
| version: ^1.2.3 |
| environment: |
| sdk: '>=2.14.0 < 3.0.0' |
| ``` |
| |
| Now you can write: |
| |
| ```yaml |
| dependencies: |
| colorizer: |
| hosted: 'https://custom-pub-server.com' |
| version: ^1.2.3 |
| environment: |
| sdk: '>=2.15.0 < 3.0.0' |
| ``` |
| |
| This feature requires |
| [language-version](https://dart.dev/guides/language/evolution#language-versioning) |
| 2.15 or later, e.g. the `pubspec.yaml` should have an SDK constraint of |
| `>=2.15 <3.0.0`. |
| |
| - Detect potential leaks in `dart pub publish`. |
| When publishing, pub will examine your files for potential secret keys, and |
| warn you. |
| |
| To ignore a file that has a false positive, add it to a |
| [`false_secrets`](https://dart.dev/go/false-secrets) section of your |
| `pubspec.yaml`. |
| - Fixes unicode terminal detection windows. |
| - New flag `--example` to the commands |
| `dart pub get/upgrade/downgrade/add/remove` that will result in the `example/` |
| folder dependencies to be updated after operating in the current directory. |
| |
| ### Other libraries |
| |
| #### `package:js` |
| |
| - Extensions on JS interop or native `dart:html` classes can now declare |
| members as `external`. These members are equivalent to regular extension |
| members that use `js_util` to expose the underlying JavaScript. |
| |
| ## 2.14.4 - 2021-10-14 |
| |
| This is a patch release that fixes: |
| |
| - a memory leak of analyzer plugins (issue [flutter/flutter#90868][]). |
| - the Dart VM sometimes loading expired certificates on Windows (issues |
| [#46370][] and [#47420][]). |
| |
| [flutter/flutter#90868]: https://github.com/flutter/flutter/issues/90868 |
| [#46370]: https://github.com/dart-lang/sdk/issues/46370 |
| [#47420]: https://github.com/dart-lang/sdk/issues/47420 |
| |
| ## 2.14.3 - 2021-09-30 |
| |
| This is a patch release that fixes: |
| |
| - a code completion performance regression (issue |
| [flutter/flutter-intellij#5761][]). |
| - debug information emitted by the Dart VM (issue [#47289][]). |
| |
| [flutter/flutter-intellij#5761]: |
| https://github.com/flutter/flutter-intellij/issues/5761 |
| [#47289]: https://github.com/dart-lang/sdk/issues/47289 |
| |
| ## 2.14.2 - 2021-09-16 |
| |
| This is a patch release that fixes: |
| |
| - two dartdoc crashes (issues [dart-lang/dartdoc#2740][] and |
| [dart-lang/dartdoc#2755][]). |
| - error messages when using the `>>>` operator on older language versions |
| (issue [#46886][]). |
| - invalid `pubspec.lock` paths on Windows (issue [dart-lang/pub#3012][]). |
| |
| [dart-lang/dartdoc#2740]: https://github.com/dart-lang/dartdoc/issues/2740 |
| [dart-lang/dartdoc#2755]: https://github.com/dart-lang/dartdoc/issues/2755 |
| [#46886]: https://github.com/dart-lang/sdk/issues/46886 |
| [#45767]: https://github.com/dart-lang/sdk/issues/45767 |
| [dart-lang/pub#3012]: https://github.com/dart-lang/pub/issues/3012 |
| |
| ## 2.14.1 - 2021-09-09 |
| |
| - Fixed an issue specific to the macOS ARM64 (Apple Silicon) SDK, where the Dart |
| commandline tools did not have the expected startup performance. |
| |
| ## 2.14.0 - 2021-09-09 |
| |
| ### Language |
| |
| - Add an unsigned shift right operator `>>>`. Pad with zeroes, ignoring the sign |
| bit. On the web platform `int.>>>` shifts the low 32 bits interpreted as an |
| unsigned integer, so `a >>> b` gives the same result as |
| `a.toUnsigned(32) >>> b` on the VM. |
| |
| - Prior to Dart 2.14, metadata (annotations) were not permitted to be specified |
| with generic type arguments. This restriction is lifted in Dart 2.14. |
| |
| ```dart |
| class C<T> { |
| const C(); |
| } |
| @C(); // Previously permitted. |
| @C<int>(); // Previously an error, now permitted. |
| ``` |
| |
| - Prior to Dart 2.14, generic function types were not permitted as arguments to |
| generic classes or functions, nor to be used as generic bounds. This |
| restriction is lifted in Dart 2.14. |
| |
| ```dart |
| T wrapWithLogging<T>(T f) { |
| if (f is void Function<T>(T x)) { |
| return <S>(S x) { |
| print("Call: f<$S>($x)"); |
| var r = f<S>(x); |
| print("Return: $x"); |
| return r; |
| } as T; |
| } // More cases here |
| return f; |
| } |
| void foo<T>(T x) { |
| print("Foo!"); |
| } |
| void main() { |
| // Previously an error, now permitted. |
| var f = wrapWithLogging<void Function<T>(T)>(foo); |
| f<int>(3); |
| } |
| ``` |
| |
| ### Core libraries |
| |
| #### `dart:async` |
| |
| - The uncaught error handlers of `Zone`s are now run in the parent zone of the |
| zone where they were declared. This prevents a throwing handler from causing |
| an infinite loop by repeatedly triggering itself. |
| |
| - Added `ignore()` as extension member on futures. |
| |
| - Added `void unawaited(Future)` top-level function to deal with the |
| `unawaited_futures` lint. |
| |
| #### `dart:core` |
| |
| - Introduce `Enum` interface implemented by all `enum` declarations. |
| |
| - The native `DateTime` class now better handles local time around daylight |
| saving changes that are not precisely one hour. (No change on the Web which |
| uses the JavaScript `Date` object.) |
| |
| - Adds static methods `hash`, `hashAll` and `hashAllUnordered` to the `Object` |
| class. These can be used to combine the hash codes of multiple objects in a |
| consistent way. |
| |
| - The `Symbol` constructor now accepts any string as argument. Symbols are equal |
| if they were created from the same string. |
| |
| |
| #### `dart:ffi` |
| |
| - Add the `DynamicLibrary.providesSymbol` function to check whether a symbol is |
| available in a dynamic library. |
| - Add `Union` native type for interacting with unions in native memory. |
| |
| #### `dart:html` |
| |
| - `convertNativeToDart_Dictionary()` now converts objects recursively, this |
| fixes APIs like MediaStreamTrack.getCapabilities that convert between Maps and |
| browser Dictionaries. [#44319] |
| - Added some access-control HTTP header names to `HttpHeaders`. |
| |
| [#44319]: https://github.com/dart-lang/sdk/issues/44319 |
| |
| #### `dart:io` |
| |
| - BREAKING CHANGE (for pre-migrated null safe code): `HttpClient`'s |
| `.authenticate` and `.authenticateProxy` setter callbacks must now accept a |
| nullable `realm` argument. |
| - Added some access-control HTTP header names to `HttpHeaders`. |
| |
| #### `dart:typed_data` |
| |
| - **BREAKING CHANGE** (https://github.com/dart-lang/sdk/issues/45115) Most types |
| exposed by this library can no longer be extended, implemented or mixed-in. |
| The affected types are `ByteBuffer`, `TypedData` and _all_ its subclasses, |
| `Int32x4`, `Float32x4`, `Float64x2` and `Endian`. |
| |
| #### `dart:web_sql` |
| |
| - `dart:web_sql` is marked deprecated and will be removed in an upcoming |
| release. Also the API `window.openDatabase` in `dart:html` is deprecated as |
| well. |
| |
| This API and library was exposing the WebSQL proposed standard. The standard |
| was abandoned more than 5 years ago and is not supported by most browsers. The |
| `dart:web_sql` library has been documented as unsupported and deprecated for |
| many years as well and but wasn't annotated properly until now. |
| |
| ### Dart VM |
| |
| - **Breaking change** [#45071][]: `Dart_NewWeakPersistentHandle`'s and |
| `Dart_NewFinalizableHandle`'s `object` parameter no longer accepts `Pointer`s |
| and subtypes of `Struct`. Expandos no longer accept `Pointer`s and subtypes of |
| `Struct`s. |
| |
| [#45071]: https://github.com/dart-lang/sdk/issues/45071 |
| |
| ### Tools |
| |
| #### Dart command line |
| |
| - **Breaking change** [#46100][]: The standalone `dart2native` tool has been |
| marked deprecated, and now prints a warning message. Its replacements are the |
| `dart compile exe` and `dart compile aot-snapshot` commands, which offer the |
| same functionality. The `dart2native` tool will be removed from the Dart SDK |
| in Dart 2.15. |
| |
| - **Breaking change**: The standalone `dartfmt` tool has been marked deprecated, |
| and now prints a warning message. Instead, use `dart format`. The `dartfmt` |
| tool will be removed from the Dart SDK in Dart 2.15. |
| |
| Note that `dart format` has [a different set of options and |
| defaults][dartfmt cli] than `dartfmt`. |
| |
| - The `dart create` command has been updated to create projects that use the new |
| 'recommended' set of lints from `package:lints`. See |
| https://dart.dev/go/core-lints for more information about these lints. |
| |
| [#46100]: https://github.com/dart-lang/sdk/issues/46100 |
| [dartfmt cli]: https://github.com/dart-lang/dart_style/wiki/CLI-Changes |
| |
| - The `dart analyze` command has been extended to support specifying multiple |
| files or directories to analyze; see also |
| https://github.com/dart-lang/sdk/issues/45352. |
| |
| - The `dartanalyzer` command's JSON output mode has been changed to emit the |
| JSON output on stdout instead of stderr. |
| |
| #### dart format |
| |
| - Simplify and optimize cascade formatting. See: |
| https://github.com/dart-lang/dart_style/pull/1033 |
| - Don't unnecessarily split argument lists with `/* */` comments. |
| - Return correct exit code from `FormatCommand` when formatting stdin. |
| - Split empty catch blocks with finally clauses or catches after them. |
| |
| #### Linter |
| |
| Updated the Linter to `1.8.0`, which includes changes that |
| - improve performance for `prefer_is_not_empty`. |
| - fix false positives in `no_logic_in_create_state`. |
| - improve `package_names` to allow dart identifiers as package names. |
| - fix a false-positive in `package_names` (causing keywords to wrongly get flagged). |
| - fix `avoid_classes_with_only_static_member` to check for inherited members and also |
| flag classes with only methods. |
| - fix `curly_braces_in_flow_control_structures` to properly flag terminating `else-if` |
| blocks. |
| - improve `always_specify_types` to support type aliases. |
| - fix a false positive in `unnecessary_string_interpolations` w/ nullable interpolated |
| strings |
| - fix a false positive in `avoid_function_literals_in_foreach_calls` for nullable |
| iterables. |
| - fix false positives in `avoid_returning_null` w/ NNBD |
| - fix false positives in `use_late_for_private_fields_and_variables` in the presence |
| of const constructors. |
| - adds a new lint: `eol_at_end_of_file`. |
| - fix case-sensitive false positive in `use_full_hex_values_for_flutter_colors`. |
| - improve try-block and switch statement flow analysis for |
| `use_build_context_synchronously`. |
| - update `use_setters_to_change_properties` to only highlight a method name, not |
| the entire body and doc comment. |
| - update `unnecessary_getters_setters` to allow otherwise "unnecessary" getters |
| and setters with annotations. |
| - update `missing_whitespace_between_adjacent_strings` to allow String |
| interpolations at the beginning and end of String literals. |
| - update `unnecessary_getters_setters` to allow for setters with non-basic |
| assignments (for example, `??=` or `+=`). |
| - relax `non_constant_identifier_names` to allow for a trailing underscore. |
| - fix false negative in `prefer_final_parameters` where first parameter is |
| final. |
| - improve `directives_ordering` sorting of directives with dot paths and |
| dot-separated package names. |
| - (internal) migrate to `SecurityLintCode` instead of deprecated |
| `SecurityLintCodeWithUniqueName`. |
| - (internal) fix `avoid_types_as_parameter_names` to skip field formal |
| parameters. |
| - fix false positives in `prefer_interpolation_to_compose_strings` where the |
| left operand is not a String. |
| - fix false positives in `only_throw_errors` for misidentified type variables. |
| - add new lint: `depend_on_referenced_packages`. |
| - update `avoid_returning_null_for_future` to skip checks for null-safe |
| libraries. |
| - add new lint: `use_test_throws_matchers`. |
| - relax `sort_child_properties_last` to accept closures after child. |
| - improve performance for `prefer_contains` and `prefer_is_empty`. |
| - add new lint: `noop_primitive_operations`. |
| - mark `avoid_web_libraries_in_flutter` as stable. |
| - add new lint: `prefer_final_parameters`. |
| - update `prefer_initializing_formals` to allow assignments where identifier |
| names don't match. |
| - update `directives_ordering` to checks ordering of `package:` imports in code |
| outside pub packages. |
| - add simple reachability analysis to `use_build_context_synchronously` to |
| short-circuit await-discovery in terminating blocks. |
| - update `use_build_context_synchronously` to recognize nullable types when |
| accessed from legacy libraries. |
| |
| #### Pub |
| |
| - `dart pub publish` now respects `.pubignore` files with gitignore-style rules. |
| `.gitignore` files in the repo are still respected if they are not overridden |
| by a `.pubignore` in the same directory. |
| |
| pub no longer queries git for listing the files. This implies: |
| |
| - Checked in files will now be ignored if they are included by a `.gitignore` |
| rule. |
| - Global ignores are no longer taken into account. |
| - Even packages that are not in git source control will have their |
| `.gitignore` files respected. |
| - `.gitignore` and `.pubignore` is always case-insensitive on MacOs and |
| Windows (as is default for `git` repositories). |
| |
| - New flag `dart pub deps --json` gives a machine parsable overview of the |
| current dependencies. |
| - New command: `dart pub cache clean`. Will delete everything in your current |
| pub cache. |
| - Commands related to a single package now takes a `--directory` option to |
| operate on a package in the given directory instead of the working directory. |
| - git dependencies with a relative repo url would previously be interpreted |
| relative to the current package, even for transitive dependencies. This now |
| fails instead. |
| |
| - Pub now uses a Dart library to read and write tar files. This should fix |
| several issues we had with incompatibilities between different system `tar`s. |
| - `PUB_HOSTED_URL` can now include a trailing slash. |
| - Incremental compilation is now used for compilation of executables from |
| dependencies when using `dart run <package>:<command>`. |
| |
| #### Dart2JS |
| |
| * **Breaking change** [#46545][]: Dart2JS emits ES6+ JavaScript by default, |
| thereby no longer supporting legacy browsers. Passing the |
| `--legacy-javascript` flag will let you opt out of this update, but this |
| flag will be removed in a future release. Modern browsers will not be |
| affected, as Dart2JS continues to support [last two major releases][1] of |
| Edge, Safari, Firefox, and Chrome. |
| |
| [#46545]: https://github.com/dart-lang/sdk/issues/46545 |
| [1]: https://dart.dev/faq#q-what-browsers-do-you-support-as-javascript-compilation-targets |
| |
| #### Dart Dev Compiler (DDC) |
| |
| - **Breaking change** [#44154][]: Subtyping relations of `package:js` classes |
| have been changed to be more correct and consistent with Dart2JS. |
| Like `anonymous` classes, non-`anonymous` classes will no longer check the |
| underlying type in DDC. The internal type representation of these objects have |
| changed as well, which will affect the `toString` value of these types. |
| |
| [#44154]: https://github.com/dart-lang/sdk/issues/44154 |
| |
| ## 2.13.4 - 2021-06-28 |
| |
| This is a patch release that fixes: |
| |
| - a Dart VM compiler crash (issue [flutter/flutter#84212][]). |
| - a DDC compiler crash (issue [flutter/flutter#82838][]). |
| |
| [flutter/flutter#84212]: https://github.com/flutter/flutter/issues/84212 |
| [flutter/flutter#82838]: https://github.com/flutter/flutter/issues/82838 |
| |
| ## 2.13.3 - 2021-06-10 |
| |
| This is a patch release that fixes: |
| |
| - a Dart compiler crash (issue [flutter/flutter#83094][]). |
| - an analysis server deadlock causing it to stop responding to IDE requests |
| (issue [#45996][]). |
| - an analyzer crash when analyzing against `package:meta` `v1.4.0` (issue |
| [#46183][]). |
| |
| [flutter/flutter#83094]: https://github.com/flutter/flutter/issues/83094 |
| [#45996]: https://github.com/dart-lang/sdk/issues/45996 |
| [#46183]: https://github.com/dart-lang/sdk/issues/46183 |
| |
| ## 2.13.1 - 2021-05-25 |
| |
| This is a patch release that fixes: |
| |
| - incorrect behavior in CastMap (issue [#45473][]). |
| - missing nullability from recursive type hierarchies in DDC (issue [#45767][]). |
| |
| [#45473]: https://github.com/dart-lang/sdk/issues/45473 |
| [#45767]: https://github.com/dart-lang/sdk/issues/45767 |
| |
| ## 2.13.0 - 2021-05-18 |
| |
| ### Language |
| |
| - **Type aliases** [Non-function type aliases][]: Type aliases (names for types |
| introduced via the `typedef` keyword) were previously restricted to only |
| introduce names for function types. In this release, we remove this |
| restriction and allow type aliases to name any kind of type. |
| |
| ```dart |
| import 'dart:convert'; |
| |
| typedef JsonMap = Map<String, dynamic>; |
| |
| JsonMap parseJsonMap(String input) => json.decode(input) as JsonMap; |
| ``` |
| |
| In addition to being usable as type annotations, type aliases that name class |
| types can now also be used anywhere that the underlying class could be used, |
| allowing type aliases to be used to safely rename existing classes. |
| |
| ```dart |
| class NewClassName<T> { |
| NewClassName.create(T x); |
| static NewClassName<T> mkOne<T>(T x) => NewClassName<T>.create(x); |
| } |
| @Deprecated("Use NewClassName instead") |
| typedef OldClassName<T> = NewClassName<T>; |
| |
| class LegacyClass extends OldClassName<int> { |
| LegacyClass() : super.create(3); |
| } |
| OldClassName<int> legacyCode() { |
| var one = OldClassName.create(1); |
| var two = OldClassName.mkOne(2); |
| return LegacyClass(); |
| } |
| ``` |
| |
| The new type alias feature is only available as part of the 2.13 |
| [language version](https://dart.dev/guides/language/evolution). To use this |
| feature, you must set the lower bound on the sdk constraint for your package |
| to 2.13 or greater. |
| |
| [non-function type aliases]: |
| https://github.com/dart-lang/language/blob/master/accepted/2.13/nonfunction-type-aliases/feature-specification.md |
| |
| ### Core libraries |
| |
| #### `dart:collection` |
| |
| - The `SplayTreeMap` was changed to allow `null` as key if the `compare` |
| function allows it. It now checks that a new key can be used as an argument to |
| the `compare` function when the member is added, _even if the map is empty_ |
| (in which case it just compares the key to itself). |
| |
| - The `SplayTreeSet` was changed to checks that a new element can be used as an |
| argument to the `compare` function when the member is added, _even if the set |
| is empty_ (in which case it just compares the element to itself). |
| |
| #### `dart:developer` |
| |
| - Added `serverWebSocketUri` property to `ServiceProtocolInfo`. |
| |
| #### `dart:ffi` |
| |
| - Add `Packed` for interacting with packed structs in native memory. |
| - Add `Array` for interacting with structs with inline arrays. |
| |
| ### Dart VM |
| |
| ### Tools |
| |
| #### Analyzer |
| |
| - Static analyses with "error" severity can once again be ignored with comments |
| like `// ignore: code` and `// ignore_for_file: code`. To declare that certain |
| analysis codes, or codes with certain severities ("error", "warning", and |
| "info") cannot be ignored with such comments, list them in |
| `analysis_options.yaml`, under the `analyzer` heading, with a new YAML key, |
| `cannot-ignore`. For example, to declare that "error" codes and |
| `unused_import` cannot be ignored, write the following into |
| `analysis_options.yaml`: |
| |
| ```yaml |
| analyzer: |
| cannot-ignore: |
| - error |
| - unused_import |
| ``` |
| |
| #### dart format |
| |
| - Correct constructor initializer indentation after `required` named parameters. |
| |
| #### Linter |
| |
| Updated the Linter to `1.2.1`, which includes: |
| |
| - Improved `iterable_contains_unrelated_type` to better support `List` content |
| checks. |
| - Fixed `camel_case_types` and `prefer_mixin` to support non-function type |
| aliases. |
| - Fixed `prefer_mixin` to properly make exceptions for `dart.collection` legacy |
| mixins. |
| - Added new lints `avoid_multiple_declarations_per_line`, |
| `use_if_null_to_convert_nulls_to_bools`, `deprecated_consistency`, |
| `use_named_constants`, `use_build_context_synchronously` (experimental). |
| - Deprecated `avoid_as`. |
| - Migrated library to null-safety. |
| |
| ### Other libraries |
| |
| #### `package:js` |
| |
| - **Breaking change:** It is no longer valid to use `String`s that match an |
| `@Native` annotation in an `@JS()` annotation for a non-anonymous JS interop |
| class. This led to erroneous behavior due to the way interceptors work. If you |
| need to work with a native class, prefer `dart:html`, an `@anonymous` class, |
| or `js_util`. See issue [#44211][] for more details. |
| |
| [#44211]: https://github.com/dart-lang/sdk/issues/44211 |
| |
| ## 2.12.4 - 2021-04-15 |
| |
| This is a patch release that fixes a Dart VM compiler crashes when compiling |
| initializers containing async closures (issue [#45306][]). |
| |
| [#45306]: https://github.com/dart-lang/sdk/issues/45306 |
| |
| ## 2.12.3 - 2021-04-14 |
| |
| **Security advisory**: This is a patch release that fixes a vulnerability in |
| `dart:html` related to DOM clobbering. See the security advisory |
| [CVE-2021-22540][cve-2021-22540] for more details. Thanks again to **Vincenzo di |
| Cicco** for finding and reporting this vulnerability. |
| |
| [cve-2021-22540]: |
| https://github.com/dart-lang/sdk/security/advisories/GHSA-3rfv-4jvg-9522 |
| |
| ## 2.12.2 - 2021-03-17 |
| |
| This is a patch release that fixes crashes reported by Flutter 2 users (issue |
| [flutter/flutter#78167][]). |
| |
| [flutter/flutter#78167]: https://github.com/flutter/flutter/issues/78167 |
| |
| ## 2.12.1 - 2021-03-10 |
| |
| This is a patch release that fixes: |
| |
| - an unhandled exception in HTTPS connections (issue [#45047][]). |
| - a typing issue in the typed_data `+` operator (issue [#45140][]). |
| |
| [#45047]: https://github.com/dart-lang/sdk/issues/45047 |
| [#45140]: https://github.com/dart-lang/sdk/issues/45140 |
| |
| ## 2.12.0 - 2021-03-03 |
| |
| ### Language |
| |
| - **Breaking change** [Null safety][] is now enabled by default in all code that |
| has not opted out. With null safety, types in your code are non-nullable by |
| default. Null can only flow into parts of your program where you want it. With |
| null safety, your runtime null-dereference bugs turn into edit-time analysis |
| errors. |
| |
| You can opt out of null safety and preserve your code's previous behavior by |
| setting the lower bound of the SDK constraint in your pubspec to 2.11.0 or |
| earlier to request an earlier [language version][]. You can opt out individual |
| Dart files by adding `// @dart=2.11` to the beginning of the file. |
| |
| Files that are opted in to null safety may report new compile-time errors. |
| Opting in to null safety also gives you access to other new language features: |
| |
| - Smarter flow analysis and type promotion |
| - `required` named parameters |
| - `late` variables |
| - The postfix `!` null assertion operator |
| - The `?..` and `?[]` null-aware operators |
| |
| - **Breaking change** [#44660][]: Fixed an implementation bug where `this` would |
| sometimes undergo type promotion in extensions. |
| |
| [null safety]: https://dart.dev/null-safety/understanding-null-safety |
| [language version]: |
| https://dart.dev/guides/language/evolution#language-versioning |
| [#44660]: https://github.com/dart-lang/sdk/issues/44660 |
| |
| ### Core libraries |
| |
| #### `dart:async` |
| |
| - Add extension method `onError()` on `Future` to allow better typing of error |
| callbacks. |
| |
| #### `dart:collection` |
| |
| - Add `UnmodifiableSetView` class, which allows users to guarantee that methods |
| that could change underlying `Set` instance can not be invoked. |
| |
| - Make it explicit that `LinkedList` compares elements by identity, and update |
| `contains()` to take advantage of this. |
| |
| #### `dart:core` |
| |
| - Add `Set.unmodifiable()` constructor, which allows users to create |
| unmodifiable `Set` instances. |
| |
| #### `dart:ffi` |
| |
| - **Breaking change** [#44621][]: Invocations with a generic `T` of `sizeOf<T>`, |
| `Pointer<T>.elementAt()`, `Pointer<T extends Struct>.ref`, and |
| `Pointer<T extends Struct>[]` are being deprecated in the current stable |
| release (2.12), and are planned to be fully removed in the following stable |
| release (2.13). Consequently, `allocate` in `package:ffi` will no longer be |
| able to invoke `sizeOf<T>` generically, and will be deprecated as well. |
| Instead, the `Allocator` it is introduced to `dart:ffi`, and also requires a |
| constant `T` on invocations. For migration notes see the breaking change |
| request. |
| |
| - **Breaking change** [#44622][]: Subtypes of `Struct` without any native member |
| are being deprecated in the current stable release (2.12), and are planned to |
| be fully removed in the following stable release (2.13). Migrate opaque types |
| to extend `Opaque` rather than `Struct`. |
| |
| [#44621]: https://github.com/dart-lang/sdk/issues/44621 |
| [#44622]: https://github.com/dart-lang/sdk/issues/44622 |
| |
| #### `dart:io` |
| |
| - `HttpRequest` now correctly follows HTTP 308 redirects |
| (`HttpStatus.permanentRedirect`). |
| |
| #### `dart:isolate` |
| |
| - Add `debugName` positional parameter to `ReceivePort` and `RawReceivePort` |
| constructors, a name which can be associated with the port and displayed in |
| tooling. |
| - Introduce `Isolate.exit([port, message])` which terminates current isolate |
| and, if `port` is specified, as a last action sends out the `message` out to |
| that `port`. |
| |
| #### `dart:html` |
| |
| - `EventStreamSubscription.cancel` has been updated to retain its synchronous |
| timing when running in both sound and unsound null safety modes. See issue |
| [#44157][] for more details. |
| |
| [#44157]: https://github.com/dart-lang/sdk/issues/44157 |
| |
| ### Dart VM |
| |
| - **Breaking change** [#42312][]: `Dart_WeakPersistentHandle`s no longer |
| auto-delete themselves when the referenced object is garbage collected to |
| avoid race conditions, but they are still automatically deleted when the |
| isolate group shuts down. |
| |
| - **Breaking change** [#42312][]: `Dart_WeakPersistentHandleFinalizer` is |
| renamed to `Dart_HandleFinalizer` and had its `handle` argument removed. All |
| API functions using that type have been updated. |
| |
| [#42312]: https://github.com/dart-lang/sdk/issues/42312 |
| |
| ### Dart2JS |
| |
| - Remove `--no-defer-class-types` and `--no-new-deferred-split`. |
| |
| ### Tools |
| |
| #### Analyzer |
| |
| - Remove the `--use-fasta-parser`, `--preview-dart-2`, and |
| `--enable-assert-initializers` command line options. These options haven't |
| been supported in a while and were no-ops. |
| |
| - Report diagnostics regarding the |
| [`@internal`](https://pub.dev/documentation/meta/latest/meta/internal-constant.html) |
| annotation. |
| |
| - Improve diagnostic-reporting regarding the |
| [`@doNotStore`](https://pub.dev/documentation/meta/latest/meta/doNotStore-constant.html) |
| annotation. |
| |
| - Introduce a diagnostic which is reported when a library member named `main` is |
| not a function. |
| |
| - Introduce a diagnostic which is reported when a `main` function's first |
| parameter is not a supertype of `List<String>`. |
| |
| - Introduce diagnostics for when an `// ignore` comment contains an error code |
| which is not being reported, cannot be ignored, or is already being ignored. |
| |
| - Report diagnostics when using |
| [`@visibleForTesting`](https://pub.dev/documentation/meta/latest/meta/ |
| visibleForTesting-constant.html) on top-level variables. |
| |
| - Fix false positive reports of "unused element" for top-level setters and |
| getters. |
| |
| - Fix false positive reports regarding `@deprecated` field formal parameters at |
| their declaration. |
| |
| - For null safety, introduce a diagnostic which reports when a null-check will |
| always fail. |
| |
| - Fix false positive reports regarding optional parameters on private |
| constructors being unused. |
| |
| - Introduce a diagnostic which is reported when a constructor includes duplicate |
| field formal parameters. |
| |
| - Improve the "unused import" diagnostic when multiple import directives share a |
| common prefix. |
| |
| - Fix false positive "unused import" diagnostic regarding an import which |
| provides an extension method which is used. |
| |
| - For null safety, improve the messaging of "use of nullable value" diagnostics |
| for eight different contexts. |
| |
| - Fix false positive reports regarding `@visibleForTesting` members in a "hide" |
| combinator of an import or export directive. |
| |
| - Improve the messaging of "invalid override" diagnostics. |
| |
| - Introduce a diagnostic which is reported when `Future<T>.catchError` is called |
| with an `onError` callback which does not return `FutureOr<T>`. |
| |
| #### dartfmt |
| |
| - Don't duplicate comments on chained if elements. |
| |
| - Preserve `?` in initializing formal function-typed parameters. |
| |
| - Fix performance issue with constructors that have no initializer list. |
| |
| #### Linter |
| |
| Updated the Linter to `0.1.129`, which includes: |