Update dependency dart to v3 #60
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "renovate_dart-3.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
>=2.12.0 <3.0.0
-><4.0.0
Release Notes
dart-lang/sdk (dart)
v3.6.0
Compare Source
Language
Dart 3.6 adds digit separators to the language. To use them, set your
package's [SDK constraint][language version] lower bound to 3.6 or greater
(
sdk: '^3.6.0'
).Digit separators
Digits in number literals (decimal integer literals, double literals,
scientific notation literals, and hexadecimal literals) can now include
underscores between digits, as "digit separators." The separators do not change
the value of a literal, but can serve to make the number more readable.
Separators are not allowed at the start of a number (this would be parsed as an
identifier), at the end of a number, or adjacent to another character in a
number, like
.
,x
, or thee
in scientific notation.to perform type inference on the operand of a
throw
expression has beenchanged from the "unknown type" to
Object
. This makes the type system moreself-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.Libraries
dart:io
Breaking Change #52444: Removed the
Platform()
constructor, whichhas been deprecated since Dart 3.1.
Breaking Change #53618:
HttpClient
now responds to a redirectthat is missing a "Location" header by throwing
RedirectException
, insteadof
StateError
.dart:js_interop
JSArrayBuffer
,JSDataView
, and concrete typed arraytypes e.g.
JSInt8Array
.length
and[]
/[]=
operators toJSArray
.toJSCaptureThis
sothis
is passed in from JavaScript to thecallback as the first parameter.
from
method onJSArray
to create aJSArray
from a givenJavaScript iterable or array-like object.
Tools
CFE
DOWN algorithms in the CFE are changed to match the specification
and the corresponding implementations in the Analyzer. The upper and
lower closures of type schemas are now computed just before they are
passed into the subtype testing procedure instead of at the very
beginning of the UP and DOWN algorithms.
Dart format
this.
orsuper.
.as
andif
clauses.Wasm compiler (dart2wasm)
dart.library.js
is now false on conditional imports indart2wasm. Note that it was already a static error to import
dart:js
directly (see #55266).
Pub
Support for workspaces. This allows you to develop and resolve multiple
packages from the same repo together. See https://dart.dev/go/pub-workspaces
for more info.
New command
dart pub bump
. Increments the version number of the currentpackage.
For example:
dart pub bump minor
will change the version from1.2.3
to1.3.0
.New validation:
dart pub publish
will warn if yourgit status
is notclean.
New flag
dart pub upgrade --unlock-transitive
.dart pub upgrade --unlock-transitive pkg
, will unlock and upgrade all thedependencies of
pkg
instead of justpkg
.Analyzer
use_truncating_division
][use_truncating_division] lint rule.omit_obvious_local_variable_types
][omit_obvious_local_variable_types] lint rule.specify_nonobvious_local_variable_types
][specify_nonobvious_local_variable_types] lint rule.avoid_futureor_void
][avoid_futureor_void] lint rule."invert conditional expression".
v3.5.4
Compare Source
v3.5.3
Compare Source
issue resulting in a missing tab bar when DevTools is embedded in
IntelliJ and Android Studio (issue#56607).
DevTools is opened instead of only the first time (issue#56607).
embedded in IntelliJ and Android Studio (issue#56607).
v3.5.2
Compare Source
ZLibDecoder
would incorrectly attempt to decompress datapast the end of the zlib footer (issue #56481).
dart
fromPATH
could result in some commands notworking as expected (issues #56080, #56306, #56499).
setContextRoots
requests orbeing provided incorrect context roots in multi-package workspaces (issue
#56475).
v3.5.1
Compare Source
include:
inanalysis_options.yaml
file in a nestedfolder in the workspace (issue#56464).
dart compile wasm
when optimizations areenabled (issue #56423).
dart2wasm
compiler in unsound-O3
/-O4
modes where aimplicit setter for a field of generic type will store
null
instead of thefield value (issue #56374).
dart2wasm
compiler that can trigger in certain situationswhen using partial instantiations of generic tear-offs (constructors or static
methods) in constant expressions (issue #56440).
also known is UP, is provided the missing implementation for
StructuralParameterType
objects. In some corner cases cases thelacking implementation resulted in a crash of the compiler (issue #56457).
v3.5.0
Compare Source
Language
Breaking Change #55418: The context used by the compiler to perform
type inference on the operand of an
await
expression has been changed tomatch 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.
Libraries
dart:core
DateTime
on the web platform now storesmicroseconds. 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 lowerdigits. This change might be breaking for apps that rely in some way on the
.microsecond
component always being zero, for example, expecting only threefractional second digits in the
toString()
representation. Smalldiscrepancies 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 theDuration
argument or resultexceeds 570 years.
dart:io
Breaking Change #55786:
SecurityContext
is nowfinal
. This meansthat
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 existingFuture<Socket>
.Fixes #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 bothList
andTypedData
. Allows abstracting over all such lists without losingaccess to either the
List
or theTypedData
members.A
ByteData
is still only aTypedData
, not a list.dart:js_interop
Breaking Change #55508:
importModule
now accepts aJSAny
insteadof a
String
to support other JS values as well, likeTrustedScriptURL
s.Breaking Change #55267:
isTruthy
andnot
now returnJSBoolean
instead of
bool
to be consistent with the other operators.Breaking Change
ExternalDartReference
no longer implementsObject
.ExternalDartReference
now accepts a type parameterT
with a bound ofObject?
to capture the type of the Dart object that is externalized.ExternalDartReferenceToObject.toDartObject
now returns aT
.ExternalDartReferenceToObject
andObjectToExternalDartReference
are nowextensions on
T
andExternalDartReference<T>
, respectively, whereT 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 JSfunction (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).
Tools
Analyzer
unintended_html_in_doc_comment
][unintended_html_in_doc_comment] lint rule.invalid_runtime_check_with_js_interop_types
][invalid_runtime_check_with_js_interop_types] lint rule.document_ignores
][document_ignores] lint rule.the switch becomes exhaustive.
const
keywords to child nodes, whereappropriate.
Pub
dart pub downgrade --tighten
to restrict lower bounds ofdependencies' 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
andDart_IsLegacyType
functions areremoved from Dart C API.
Dart_DefaultCanonicalizeUrl
is removed from the Dart C API.v3.4.4
Compare Source
This is a patch release that:
Fixes an issue where pub would crash when failing to fetch advisories from
the server. (issue pub#4269).
Fixes an issue where
const bool.fromEnvironment('dart.library.ffi')
is trueand conditional import condition
dart.library.ffi
is true in dart2wasm.(issue #55948).
Fixes an issue where FFI calls with variadic arguments on MacOS Arm64
would mangle the arguments. (issue #55943).
v3.4.3
Compare Source
This is a patch release that:
Fixes an issue where
DART_VM_OPTIONS
were not correctly parsed forstandalone Dart executables created with
dart compile exe
(issue#55818).
Fixes a bug in dart2wasm that can result in a runtime error that says
array.new_fixed()
has a constant larger than 10000 (issue #55873).Adds support for
--enable-experiment
flag todart compile
wasm(issue #55894).
Fixes an issue in dart2wasm compiler that can result in incorrect
nullability of type parameter (see #55895).
Disallows
dart:ffi
imports in user code in dart2wasm (e.g. issuev3.4.2
Compare Source
This is a patch release that:
Marks
dart compile wasm
as no longer experimental.Fixes two bugs in exception handling in
async
functions in dart2wasm(issues #55347, #55457).
Fixes restoration of
this
variable insync*
andasync
functions indart2wasm.
Implements missing control flow constructs (exceptions, switch/case with
yields) in
sync*
in dart2wasm (issues #51342, #51343).Fixes a bug dart2wasm compiler that surfaces as a compiler crash when indexing
lists where the compiler proofs the list to be constant and the index is
out-of-bounds (issue #55817).
v3.4.1
Compare Source
This is a patch release that:
Fixes a bug in the CFE which could manifest as compilation errors of Flutter
web apps when compiled with dart2wasm (issue #55714).
Fixes a bug in the pub client, such that
dart run
will not interfere withFlutter l10n (at least for most cases) (issue #55758).
v3.4.0
Compare Source
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 takeadvantage of these improvements, set your package's
SDK constraint lower bound to 3.4 or greater
(
sdk: '^3.4.0'
).Breaking Change #54640: The pattern context type schema for
cast patterns has been changed from
Object?
to_
(the unknowntype), 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 whatcurrently 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.
Libraries
dart:async
ParallelWaitError
to get some meta-information thatit can expose in its
toString
, and theIterable<Future>.wait
and(Future,...,Future).wait
extension methods now provide that information.Should make a
ParallelWaitError
easier to log.dart:cli
waitFor
is removed in 3.4.dart:ffi
Struct.create
andUnion.create
to create struct and union viewsof the sequence of bytes stored in a subtype of
TypedData
.dart:io
Breaking change #53863:
Stdout
has a new fieldlineTerminator
,which allows developers to control the line ending used by
stdout
andstderr
. Classes thatimplement Stdout
must define thelineTerminator
field. The default semantics of
stdout
andstderr
are not changed.Deprecates
FileSystemDeleteEvent.isDirectory
, which always returnsfalse
.dart:js_interop
Fixes an issue with several comparison operators in
JSAnyOperatorExtension
that were declared to return
JSBoolean
but really returnedbool
. This ledto runtime errors when trying to use the return values. The implementation now
returns a
JSBoolean
to align with the interface. See issue #55024 formore details.
Added
ExternalDartReference
and related conversion functionstoExternalReference
andtoDartObject
. This is a faster alternative toJSBoxedDartObject
, but with fewer safety guarantees and fewerinteroperability capabilities. See #55187 for more details.
On dart2wasm,
JSBoxedDartObject
now is an actual JS object that wraps theopaque 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.
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: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.
Tools
Analyzer
Improved code completion. Fixed over 50% of completion correctness bugs,
tagged
analyzer-completion-correctness
in the issuetracker.
Support for new annotations introduced in version 1.14.0 of the meta
package.
Support for the [
@doNotSubmit
][@doNotSubmit] annotation, noting that any usage of anannotated member should not be submitted to source control.
Support for the [
@mustBeConst
][@mustBeConst] annotation, which indicates that anannotated parameter only accepts constant arguments.
Linter
unnecessary_library_name
][unnecessary_library_name] lint.missing_code_block_language_in_doc_comment
][missing_code_block_language_in_doc_comment] lint.Compilers
value
""
for alldart.library.foo
strings, wheredart:foo
is not anavailable 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 onconst bool.fromEnvironment(...)
orconst String.fromEnvironment(...)
without adefaultValue
argument, anargument which was always ignored previously. It changes the behavior of
const bool.hasEnvironment(...)
on such an input, away from always beingtrue
and therefore useless.DevTools
To learn more, check out the release notes for versions
2.32.0 and 2.33.0.
Pub
Dependency resolution and
dart pub outdated
will now surface if a dependencyis affected by a security advisory, unless the advisory is listed under a
ignored_advisories
section in thepubspec.yaml
file. To learn more aboutpub's support for security advisories, visit
dart.dev/go/pub-security-advisories.
path
-dependencies insidegit
-dependencies are now resolved relative to thegit repo.
All
dart pub
commands can now be run from any subdirectory of a project. Pubwill find the first parent directory with a
pubspec.yaml
and operaterelative it.
New command
dart pub unpack
that downloads a package from pub.dev andextracts it to a subfolder of the current directory.
This can be useful for inspecting the code, or playing with examples.
Dart Runtime
Dart VM flags and options can now be provided to any executable generated
using
dart compile exe
via theDART_VM_OPTIONS
environment variable.DART_VM_OPTIONS
should be set to a list of comma-separated flags and optionswith 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:Dart VM no longer supports external strings:
Dart_IsExternalString
,Dart_NewExternalLatin1String
andDart_NewExternalUTF16String
functions areremoved from Dart C API.
v3.3.4
Compare Source
This is a patch release that:
the enclosing library's
@JS
annotation were actually using the invocation'senclosing library's
@JS
annotation. (issue #55430).v3.3.3
Compare Source
This is a patch release that:
v3.3.2
Compare Source
This is a patch release that:
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).
resolved in initializers of extension types (issue #55194).
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).
v3.3.1
Compare Source
This is a patch release that:
extension types would fail to compile without an
@JS
annotation on thelibrary (issue #55057).
operand of an
await
expression, unless the extension type itself implementsFuture
(issue #55095).v3.3.0
Compare Source
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
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:
The declaration
Meters
is an extension type that has representation typeint
. It introduces an implicit constructorMeters(int value);
and agetter
int get value
.m
andm.value
is the very same object, butm
has type
Meters
andm.value
has typeint
. The point is thatm
has the members of
Meters
andm.value
has the members ofint
.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
, theno
is just a normal object whoserun-time type is a subtype of
R
, exactly like the value of an expressionof type
R
. Also the run-time value ofE
isR
(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 actuallychecks 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:
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:
Affected code can be fixed by adding an explicit type annotation.
For example, in the above snippet,
var x
can be changed toint? 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.
Libraries
dart:core
String.fromCharCodes
now allowstart
andend
to be after the end ofthe
Iterable
argument, just likeskip
andtake
does on anIterable
.dart:ffi
@Native
can now be used on fields.Native.addressOf
.elementAt
pointer arithmetic extension methods oncore
Pointer
types are now deprecated.Migrate to the new
-
and+
operators instead.@FfiNative
annotation has been removed.Usages should be updated to use the
@Native
annotation.dart:js_interop
like
JSAny
were previously represented using a custom erasure of@staticInterop
types that were compiler-specific. They are now representedas extension types where their representation types are compiler-specific.
This means that user-defined
@staticInterop
types that implementedJSAny
or
JSObject
can no longer do so and need to useJSObject.fromInteropObject
. Going forward, it's recommended to use extensiontypes to define interop APIs. Those extension types can still implement JS
types.
JSArray
andJSPromise
are now generictypes whose type parameter is a subtype of
JSAny?
. Conversions to and fromthese types are changed to account for the type parameters of the Dart or JS
type, respectively.
dart:js_interop
extensionmembers are moved to different extensions on the same type or a supertype to
better organize the API surface. See
JSAnyUtilityExtension
andJSAnyOperatorExtension
for the new extensions. This shouldn't make adifference unless the extension names were explicitly used.
importModule
to allow users to dynamically import modules using the JSimport()
expression.dart:js_interop_unsafe
has
helper to makehasProperty
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.
use the new
asUnmodifiableView()
methods: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
base
sothat 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.
Tools
Dart command line
dart create
command now uses v3 ofpackage: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.DevTools
To learn more, check out the release notes for versions
2.29.0, 2.30.0,
and 2.31.0.
Wasm compiler (dart2wasm)
dart:js_util
,package:js
, anddart:js
are now disallowed from being imported when compiling with
dart2wasm
. Preferusing
dart:js_interop
anddart:js_interop_unsafe
.Development JavaScript compiler (DDC)
Type arguments of
package:js
interop types are now printed asany
insteadof 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)
The
Invocation
that is passed tonoSuchMethod
will no longer have aminified
memberName
, even when dart2js is invoked with--minify
.See #54201 for more details.
Analyzer
pubspec.yaml
files byadding an
# ignore: <diagnostic_id>
comment.dart doc
comment directives are now reported.flutter_style_todos
][flutter_style_todos] lint now has a quick fix.Linter
iterable_contains_unrelated_type
andlist_remove_unrelated_type
lints.Consider migrating to the expanded
[
collection_methods_unrelated_type
][collection_methods_unrelated_type] lint.always_require_non_null_named_parameters
avoid_returning_null
,avoid_returning_null_for_future
v3.2.6
Compare Source
v3.2.5
Compare Source
v3.2.4
Compare Source
v3.2.3
Compare Source
This is a patch release that:
(issue #54232).
environments that don't support the integer division
instructions or x86-64 environments that don't support
SSE4.1 (issue #54215).
v3.2.2
Compare Source
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).
v3.2.1
Compare Source
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).
v3.2.0
Compare Source
Language
Dart 3.2 adds the following features. To use them, set your package's SDK
constraint lower bound to 3.2 or greater (
sdk: '^3.2.0'
).Private field promotion: In most circumstances, the types of private final
fields can now be promoted by null checks and
is
tests. For example:To ensure soundness, a field is not eligible for field promotion in the
following circumstances:
test and the usage, invalidating the promotion).
non-final field (because an access to an overridden field might resolve at
runtime to the overriding getter or field).
elsewhere in the program).
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).
C
in the library whose interface contains agetter with the same name, but
C
does not have an implementation of thatgetter (such unimplemented getters aren't safe for field promotion, because
they are implicitly forwarded to
noSuchMethod
, which might not return thesame 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.
Libraries
dart:async
broadcast
parameter toStream.empty
constructor.dart:cli
waitFor
is disabled by default and slated for removal in 3.4. Attemptingto call this function will now throw an exception. Users that still depend
on
waitFor
can enable it by passing--enable_deprecated_wait_for
flagto the VM.
dart:convert
utf8.encode()
andUtf8Codec.encode()
fromList<int>
toUint8List
.dart:developer
Service.getIsolateID
method.getIsolateId
method toService
.getObjectId
method toService
.dart:ffi
NativeCallable.isolateLocal
constructor. This createsNativeCallable
s with the same functionality asPointer.fromFunction
,except that
NativeCallable
accepts closures.NativeCallable.keepIsolateAlive
method, which determines whetherthe
NativeCallable
keeps the isolate that created it alive.NativeCallable
constructors can now accept closures. PreviouslyNativeCallable
s had the same restrictions asPointer.fromFunction
, andcould only create callbacks for static functions.
NativeCallable.nativeFunction
now throws anerror if is called after the
NativeCallable
has already beenclose
d. Callsto
close
after the first are now ignored.dart:io
Breaking change #53005: The headers returned by
HttpClientResponse.headers
andHttpRequest.headers
no longer includetrailing whitespace in their values.
Breaking change #53227: Folded headers values returned by
HttpClientResponse.headers
andHttpRequest.headers
now have a spaceinserted at the fold point.
dart:isolate
Isolate.packageConfigSync
andIsolate.resolvePackageUriSync
APIs.dart:js_interop
JSNumber.toDart
is removed in favor oftoDartDouble
andtoDartInt
tomake the type explicit.
Object.toJS
is also removed in favor ofObject.toJSBox
. Previously, this function would allow Dart objects to flowinto JS unwrapped on the JS backends. Now, there's an explicit wrapper that is
added and unwrapped via
JSBoxedDartObject.toDart
. Similarly,JSExportedDartObject
is renamed toJSBoxedDartObject
and the extensionsObjectToJSExportedDartObject
andJSExportedDartObjectToObject
are renamedto
ObjectToJSBoxedDartObject
andJSBoxedDartObjectToObject
in order toavoid confusion with
@JSExport
.Type parameters must now be bound to a static interop type or one of the
dart:js_interop
types likeJSNumber
when used in an external API. Thisonly affects
dart:js_interop
classes and notpackage:js
or other forms ofJS interop.
dart:js_interop
types:@staticInterop
types can subtype onlyJSObject
andJSAny
from the set ofJS types in
dart:js_interop
. Subtyping other types fromdart:js_interop
would result in confusing type errors before, so this makes it a static error.
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 usedJavaScript's
globalThis
as the global context. This is relevant to thingslike 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'sglobal
in non-staticinterop APIs with
package:js
. So, static interop APIs will now use one ofthose global contexts. Functionally, this should matter in only a very small
number of cases, like when using older browser versions.
dart:js_interop
'sglobalJSObject
is also renamed toglobalContext
and returns the globalcontext used in the lowerings.
dart:js_interop
External APIs:External JS interop APIs when using
dart:js_interop
are restricted to a setof allowed types. Namely, this includes the primitive types like
String
, JStypes from
dart:js_interop
, and other static interop types (either through@staticInterop
or extension types).dart:js_interop
isNull
andisUndefined
:null
andundefined
can only be discerned in the JS backends. dart2wasmconflates 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.
dart:js_interop
typeofEquals
andinstanceof
:Both APIs now return a
bool
instead of aJSBoolean
.typeofEquals
alsonow takes in a
String
instead of aJSString
.dart:js_interop
JSAny
andJSObject
:These types can only be implemented, and no longer extended, by user
@staticInterop
types.dart:js_interop
JSArray.withLength
:This API now takes in an
int
instead ofJSNumber
.Tools
Development JavaScript compiler (DDC)
JavaScript Object prototype.
JavaScript
Symbol
s andBigInt
s are now associated with their owninterceptor and should not be used with
package:js
classes. These types werebeing intercepted with the assumption that they are a subtype of JavaScript's
Object
, but this is incorrect. This lead to erroneous behavior when usingthese types as Dart
Object
s. See #53106 for more details. Usedart:js_interop
'sJSSymbol
andJSBigInt
with extension types to interopwith these types.
Production JavaScript compiler (dart2js)
JavaScript
Symbol
s andBigInt
s are now associated with their owninterceptor and should not be used with
package:js
classes. These types werebeing intercepted with the assumption that they are a subtype of JavaScript's
Object
, but this is incorrect. This lead to erroneous behavior when usingthese types as Dart
Object
s. See #53106 for more details. Usedart:js_interop
'sJSSymbol
andJSBigInt
with extension types to interopwith these types.
Dart command line
dart create
command has a newcli
templateto quickly create Dart command-line applications
with basic argument parsing capabilities.
To learn more about using the template,
run
dart help create
.Dart format
--enable-experiment
command-line option to enable languageexperiments.
DevTools
2.28.1 releases of DevTools.
Linter
annotate_redeclares
][annotate_redeclares] lint.use_build_context_synchronously
][use_build_context_synchronously] lint as stable.Pub
dart pub upgrade --tighten
which will update dependencies' lowerbounds in
pubspec.yaml
to match the current version.dart pub get
/add
/upgrade
will now show if a dependencychanged between direct, dev and transitive dependency.
dart pub upgrade
no longer shows unchanged dependencies.v3.1.5
Compare Source
This is a patch release that:
change in Node.js 21 affected the Dart Web compiler runtime. This patch
release accommodates for those changes (issue #53810).
v3.1.4
Compare Source
This is a patch release that:
value of variables while debugging code (issue [#53747]).
v3.1.3
Compare Source
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 (seeissue #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 differentversions 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)
v3.1.2
Compare Source
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)
v3.1.1
Compare Source
This is a patch release that:
nested record pattern, where the nested record pattern uses record
destructuring shorthand syntax, for example
final ((:a, :b), c) = record;
(issue #53352).
v3.1.0
Compare Source
Libraries
dart:async
interface
modifier to purely abstract classes:MultiStreamController
,StreamConsumer
,StreamIterator
andStreamTransformer
. As a result, these types can only be implemented,not extended or mixed in.
dart:core
Uri.base
on native platforms now respectsIOOverrides
overridingcurrent directory (#39796).
dart:ffi
NativeCallable
class, which can be used to create callbacks thatallow native code to call into Dart code from any thread. See
NativeCallable.listener
. In future releases,NativeCallable
will beupdated with more functionality, and will become the recommended way of
creating native callbacks for all use cases, replacing
Pointer.fromFunction
.dart:io
sameSite
to theCookie
class.SameSite
.FileSystemEvent
issealed
. This meansthat
FileSystemEvent
cannot be extended or implemented.Platform
is instantiated.Platform.lineTerminator
which exposes the character or charactersthat the operating system uses to separate lines of text, e.g.,
"\r\n"
on Windows.dart:js_interop
ObjectLiteral
is removed fromdart:js_interop
. It's no longer needed inorder 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
@staticInterop
andexternal
extension members:external
@staticInterop
members andexternal
extension members can nolonger be used as tear-offs. Declare a closure or a non-
external
method thatcalls these members, and use that instead.
@staticInterop
andexternal
extension members:external
@staticInterop
members andexternal
extension members willgenerate 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])
asfoo(0)
will now result infoo(0)
, and notfoo(0, null)
.Tools
DevTools
releases of DevTools.
Linter
your package's
analysis_options.yaml
file:no_self_assignments
no_wildcard_variable_uses
v3.0.7
Compare Source
This is a patch release that:
bad codegen causing a
TypeError
orNoSuchMethodError
to be thrownat runtime (issue #53001).
v3.0.6
Compare Source
This is a patch release that:
assignments (issue #52767).
is
oras
expressions involving record types with named fields (issue #52869).v3.0.5
Compare Source
This is a patch release that:
ListFactorySpecializer
during Flutter web builds (issue #52403).v3.0.4
Compare Source
This is a patch release that:
dart format
now handles formatting nullable record typeswith no fields (dart_style issue #1224).
(issue #52480).
v3.0.3
Compare Source
This is a patch release that:
returning an unboxed record (issue #52449).
or-pattern might be erroneously reported as being mismatched (issue #52373).
interface
modifiers on the purely abstract classesMultiStreamController
,StreamConsumer
,StreamIterator
andStreamTransformer
(issue #52334).InternetAddress.tryParse
isused (issue #52423).
a pattern match using a variable or wildcard pattern with a nullable
record type (issue #52439).
cache on Windows (issue #52386).
v3.0.2
Compare Source
This is a patch release that:
the fields don't match the cases (issue #52438).
generated with
dart doc
(issue #3392).leading to higher memory usage (issue #52352).
(issue: #52078).
v3.0.1
Compare Source
This is a patch release that:
(issue #124369).
and records (issue #51899).
void
in a switch case expression(issue #52191).
refers to a private getter (issue #52041).
when
andas
as variable names in patterns(issue #52260).
(issue #52241).
v3.0.0
Compare Source
Language
Dart 3.0 adds the following features. To use them, set your package's SDK
constraint lower bound to 3.0 or greater (
sdk: '^3.0.0'
).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:
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:
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:
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:
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:
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 thatswitches 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:
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
, andmixin
on
class
andmixin
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
. If you want it to be used only as a mixin, make it amixin
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
andwhile
statements) or aswitch
member. Fix this by changing thecontinue
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 theseparator before the default value of an optional named parameter.
Fix this by changing the colon (
:
) to an equal sign (=
).Libraries
General changes
mixin
classes in the platform librariescan 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 forIterable
)IterableBase
(now alias forIterable
)ListMixin
SetMixin
MapMixin
LinkedListEntry
StringConversionSink
dart:core
Added
bool.parse
andbool.tryParse
static methods.Added
DateTime.timestamp()
constructor to get current time as UTC.The type of
RegExpMatch.pattern
is nowRegExp
, not justPattern
.Breaking change #49529:
List
constructor, as it wasn't null safe.Use list literals (e.g.
[]
for an empty list or<int>[]
for an emptytyped list) or [
List.filled
][List.filled].onError
argument on [int.parse
][int.parse], [double.parse
][double.parse],and [
num.parse
][num.parse]. Use the [tryParse
][tryParse] method instead.proxy
][proxy] and [Provisional
][Provisional] annotations.The original
proxy
annotation has no effect in Dart 2,and the
Provisional
type and [provisional
][provisional] constantwere only used internally during the Dart 2.0 development process.
Deprecated.expires
][Deprecated.expires] getter.Use [
Deprecated.message
][Deprecated.message] instead.CastError
][CastError] error.Use [
TypeError
][TypeError] instead.FallThroughError
][FallThroughError] error. The kind offall-through previously throwing this error was made a compile-time
error in Dart 2.0.
NullThrownError
][NullThrownError] error. This error is neverthrown from null safe code.
AbstractClassInstantiationError
][AbstractClassInstantiationError] error. It was madea compile-time error to call the constructor of an abstract class in Dart 2.0.
CyclicInitializationError
][CyclicInitializationError]. Cyclic dependencies areno longer detected at runtime in null safe code. Such code will fail in other
ways instead, possibly with a StackOverflowError.
NoSuchMethodError
][NoSuchMethodError] default constructor.Use the [
NoSuchMethodError.withInvocation
][NoSuchMethodError.withInvocation] named constructor instead.BidirectionalIterator
][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 allowedfor backwards compatibility, but it has not had any effect.
In Dart 3.0, the
Function
type isfinal
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 intendedas 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.
dart:async
Added extension member
wait
on iterables and 2-9 tuples of futures.Breaking change #49529:
DeferredLibrary
][DeferredLibrary] class.Use the [
deferred as
][deferred as] import syntax instead.dart:collection
Added extension members
nonNulls
,firstOrNull
,lastOrNull
,singleOrNull
,elementAtOrNull
andindexed
onIterable
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.
Queue
LinkedList
LinkedListEntry
or extended:
HasNextIterator
(Also deprecated.)HashMap
LinkedHashMap
HashSet
LinkedHashSet
DoubleLinkedQueue
ListQueue
SplayTreeMap
SplayTreeSet
dart:developer
Breaking change #49529:
MAX_USER_TAGS
][MAX_USER_TAGS] constant.Use [
maxUserTags
][maxUserTags] instead.Callbacks passed to
registerExtension
will be run in the zone from whichthey are registered.
Breaking change #50231:
Metrics
][Metrics], [Metric
][Metric], [Counter
][Counter],and [
Gauge
][Gauge] classes as they have been broken since Dart 2.0.dart:ffi
@FfiNative
annotation is now deprecated.Usages should be replaced with the new
@Native
annotation.dart:html
registerElement
and
registerElement2
methods inDocument
andHtmlDocument
have beenremoved. See #49536 for
details.
dart:math
Some changes to platform libraries only affect code when it is migrated
to language version 3.0.
Random
interface can only be implemented, not extended.dart:io
name
andsignalNumber
to theProcessSignal
class.NetworkInterface.listSupported
. Has always returned true sinceDart 2.3.
httpEnableTimelineLogging
parameter name transition fromenable
to
enabled
. See #43638.#50868.
NetworkProfiling
to accommodate newString
idsthat are introduced in vm_service:11.0.0
dart:js_util
delete
and thetypeof
functionality.jsify
is now permissive and has inverse semantics todartify
.jsify
anddartify
both handle types they understand natively moreefficiently.
callMethod
has been aligned with the other methods andnow takes
Object
instead ofString
.Tools
Observatory
DevTools. Users requiring specific functionality in Observatory should set
the
--serve-observatory
flag.Web Dev Compiler (DDC)
-k
,--kernel
, and--dart-sdk
.--nativeNonNullAsserts
, which ensures web library APIsare sound in their nullability, is by default set to true in sound mode. For
more information on the flag, see NATIVE_NULL_ASSERTIONS.md.
dart2js
--native-null-assertions
, which ensures web libraryAPIs 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 moreinformation on the flag, see NATIVE_NULL_ASSERTIONS.md.
Dart2js
the internal dart2js snapshot fails unless it is called from a supported
interface, such as
dart compile js
,flutter build
, orbuild_web_compilers
. This is not expected to be a visible change.Formatter
sync*
andasync*
functions with=>
bodies.<
in collection literals.Analyzer
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 nowconsidered "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 acode-by-code basis, by changing the severity of rules in an analysis
options file.
@Since
annotation. When code in apackage uses a Dart SDK element annotated with
@Since
, analyzer will reporta warning if the package's Dart SDK constraint allows versions of Dart
which don't include that element.
the number of plugins per analysis context to 1. (issue [#50981][]).
Linter
Updates the Linter to
1.35.0
, which includes changes thatimplicit_reopen
unnecessary_breaks
type_literal_in_constant_pattern
invalid_case_patterns
enable_null_safety
invariant_booleans
prefer_bool_in_asserts
prefer_equal_for_default_values
super_goes_last
unnecessary_parenthesis
false-positives with null-aware expressions.void_checks
to allow assignments ofFuture<dynamic>?
to parameterstyped
FutureOr<void>?
.use_build_context_synchronously
in if conditions.avoid_private_typedef_functions
with generalizedtype aliases.
unnecessary_parenthesis
to detect some doubled parens.void_checks
to allow returningNever
as void.no_adjacent_strings_in_list
to support set literals and for- andif-elements.
avoid_types_as_parameter_names
to handle type variables.avoid_positional_boolean_parameters
to handle typedefs.avoid_redundant_argument_values
to check parameters of redirectingconstructors.
prefer_const_literals_to_create_immutables
.use_build_context_synchronously
to check context properties.unnecessary_parenthesis
support for property accesses and methodinvocations.
unnecessary_parenthesis
to allow parentheses in more null-awarecascade contexts.
unreachable_from_main
to track static elements.unnecessary_null_checks
to not report on arguments passed toFuture.value
orCompleter.complete
.always_use_package_imports
andprefer_relative_imports
asincompatible rules.
only_throw_errors
to not report onNever
-typed expressions.unnecessary_lambdas
to not report withlate final
variables.avoid_function_literals_in_foreach_calls
to not report with nullable-typed targets.
deprecated_member_use_from_same_package
which replaces thesoft-deprecated analyzer hint of the same name.
public_member_api_docs
to not require docs on enum constructors.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 stillhave 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 anupper 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 aboutdependency_overrides
. Dependencyoverrides only take effect in the root package of a resolution.
dart pub token add
now verifies that the given token is valid for includingin a header according to RFC 6750 section
2.1. This means they must
contain only the characters:
^[a-zA-Z0-9._~+/=-]+$
. Before a failure wouldhappen when attempting to send the authorization header.
dart pub get
and related commands will now by default also update thedependencies in the
example
folder (if it exists). Use--no-example
toavoid this.
On Windows the
PUB_CACHE
has moved to%LOCALAPPDATA%
, since Dart 2.8 thePUB_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 orearlier. If you have
path/to/.pub-cache/bin
inPATH
you may need toupdate your
PATH
.Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.
⚠ Artifact update problem
Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.
♻ Renovate will retry this branch, including artifacts, only when one of the following happens:
The artifact failure details are included below:
File name: pubspec.lock