Breaking changes and deprecations
- 3.6.0
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.10.0
- 2.9.0
- 2.8.1
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
This page lists all language and library breaking changes and deprecations in Dart, organized by release and area, to help Dart users understand and manage their impact. Complete release notes are available in the Dart SDK changelog. The breaking change policy document describes the policy and process around breaking changes and deprecations in Dart.
This page includes the following types of breaking changes:
Unversioned: The Dart SDK does not maintain backward compatibility, and code may break as soon as you upgrade your sdk version if it relies on the previous behavior.
These are the majority of changes and are not specially marked in this list.
Language versioned: The Dart SDK maintains backward compatibility for existing code, and the behavior change only takes effect (potentially breaking code that relies on the previous behavior) when you upgrade the language version of your code.
These are marked as: Language versioned
Deprecations: The Dart SDK maintains compatibility for deprecated code, with a warning. Deprecations are then completely removed in a subsequent release, breaking any code that relies on the previous behavior.
These are marked as: Deprecated / Removed
Experimental: Part of the release but not yet treated as stable in the SDK, and can break from one version to another. Experimental changes do not always have a corresponding breaking change issue, but may have more detail in the SDK changelog.
These are marked: Experimental
If you have questions or concerns about any of these breaking changes, please comment on the breaking change issue linked from the relevant entry. To be notified about future breaking changes, join the Dart announce group.
3.6.0
#Tentative
The following changes are expected to be included in the 3.6 stable release, but the final list will likely change before then. To reduce the potential impact of these changes, consider accounting for them before the 3.6 release.
Language
#- The context used by Dart 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 thrownull
. This change is not expected to make any difference in practice.
3.5.0
#Language
#- 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. - 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. The old behavior can be restored by supplying explicit types.
Libraries
#dart:core
#DateTime
now stores microseconds on the web platform, more closely matching the behavior on native platforms.
dart:io
#dart:js_interop
#importModule
now accepts aJSAny
instead of aString
to support other JS values as well, such asTrustedScriptURL
objects.isTruthy
andnot
now returnJSBoolean
instead ofbool
to be consistent with other JS operator methods.ExternalDartReference
no longer implementsObject
. Instead, it now accepts a type parameter (T
) with a bound ofObject?
to capture the type of the Dart object that is externalized.
dart:typed_data
#- Removed The unmodifiable view classes for typed data have been removed. Instead of using the constructors of these classes, use the new
asUnmodifiableView
methods on typed data lists.
Runtime
#- Removed The Dart VM no longer supports unsound null safety.
- The
--no-sound-null-safety
CLI option has been removed. - The
Dart_NewListOf
andDart_IsLegacyType
functions have been removed from the C API.
- The
- Removed The
Dart_DefaultCanonicalizeUrl
function has been removed from the C API.
3.4.0
#Language
#- The pattern context type schema for cast patterns is now
_
(the unknown type) instead ofObject?
. - The type schema used by the Dart compilers 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.
Libraries
#dart:cli
#- Experimental Removed The
waitFor
function has been removed.
dart:html
, dart:indexed:db
, dart:svg
, dart:web_audo
, dart:web_gl
#- Deprecated These libraries are now marked as legacy and will see less support in the future. New projects should prefer to use
package:web
anddart:js_interop
. To learn more, check out Migrate to package:web.
dart:js
#- Deprecated This library is now marked as legacy and will see less support in the future. Usages should be migrated to
dart:js_interop
anddart:js_interop_unsafe
. To learn more, check out/go/next-gen-js-interop
.
dart:js_util
#- Deprecated This library is now marked as legacy and will see less support in the future. Usages should be migrated to
dart:js_interop
anddart:js_interop_unsafe
. To learn more, check out/go/next-gen-js-interop
.
dart:io
#Stdout
has a new fieldlineTerminator
, which allows developers to control the line ending used bystdout
andstderr
. Classes that implementStdout
must define thelineTerminator
field. The default semantics ofstdout
andstderr
are not changed.- Deprecated The
FileSystemDeleteEvent.isDirectory
property. It always returnsfalse
.
dart:typed_data
#- Deprecated The unmodifiable view classes for typed data are deprecated. Instead of using the constructors of these classes, use the new
asUnmodifiableView
methods on typed data lists.
Tools
#Production JavaScript compiler (dart2js)
#- Experimental Deprecated You should now specify a format to the
--dump-info
CLI option of eitherbinary
orjson
. Thejson
format is deprecated and might be removed in a future Dart release.
Wasm compiler (dart2wasm)
#- Experimental Various
dart compile wasm
CLI arguments have been updated, removed, or replaced. To learn more, rundart compile wasm --verbose --help
.
Runtime
#- Removed The Dart VM longer supports external strings. As a result, the
Dart_IsExternalString
,Dart_NewExternalLatin1String
, andDart_NewExternalUTF16String
functions have been removed from the Dart C API.
3.3.0
#SDK
#Experimental Removed The following experiments are now retired as they were released in Dart 3 and are no longer necessary with a language version of 3.0 or greater. Configuration of them should be removed from analysis options, CLI commands, and IDE configurations.
patterns
records
class-modifers
sealed-class
Language
#Libraries
#dart:cli
#- Experimental Deprecated The
waitFor
function remains deprecated for another release and is set for removal in Dart 3.4.
dart:ffi
#- Deprecated The
elementAt
pointer arithmetic methods onPointer
types are deprecated. Migrate to the-
and+
operators instead. - Experimental Removed The previously deprecated
@FfiNative
annotation has been removed. Usages should be updated to use the@Native
annotation.
dart:html
#- Instead of using
HttpRequest
directly, it is now recommended to usepackage:http
.
dart:io
#- Instead of using
HttpClient
directly, it is now recommended to usepackage:http
.
dart:js_interop
#- Experimental JS types like
JSAny
have new compiler-specific representation types. - Experimental User-defined
@staticInterop
classes can no longer implementJSAny
orJSObject
. Usages should be migrated toJSObject.fromInteropObject
or be defined as extension types. - Experimental
JSArray
andJSPromise
now have generic parameters. - Experimental Various extension members were moved or renamed. To learn about the updated extensions, reference
JSAnyUtilityExtension
andJSAnyOperatorExtension
.
dart:typed_data
#- The unmodifiable view classes for typed data will be deprecated in Dart 3.4. Instead of using the constructors of these classes, use the new
asUnmodifiableView
methods on typed data lists.
dart:nativewrappers
#- Experimental All native wrapper classes are now marked
base
so that none of their subtypes can be implemented.
Tools
#Production JavaScript compiler (dart2js)
#- The
Invocation
that is passed tonoSuchMethod
no longer has a minifiedmemberName
, even when compiled with--minify
.
Wasm compiler (dart2wasm)
#- Experimental Disallow importing legacy JS interop libraries. Prefer using
dart:js_interop
anddart:js_interop_unsafe
instead.
Analyzer
#Experimental Invalid
dart doc
comment directives are now reported by the analyzer.Due to improvements in type promotion, the following analyzer diagnostics might trigger on existing code that previously passed analysis:
unnecessary_non_null_assertion
unnecessary_cast
invalid_null_aware_operator
Linter
#The
iterable_contains_unrelated_type
andlist_remove_unrelated_type
lints were removed. Consider migrating to the expandedcollection_methods_unrelated_type
lint.The following lints are removed due to no longer being necessary with sound null safety. You should remove configuration of them from your
analysis_options.yaml
files and any ignore comments.always_require_non_null_named_parameters
avoid_returning_null
avoid_returning_null_for_future
3.2.0
#Language
#- Language versioned Changed the split point for refutable patterns to the top level pattern so type promotion in if-case statements is consistent regardless of whether the scrutinee might throw an exception.
Libraries
#dart:cli
#- Experimental Deprecated The
waitFor
function.
dart:convert
#- Changed return types of
utf8.encode()
andUtf8Codec.encode()
fromList<int>
toUint8List
.
dart:developer
#- Deprecated The
Service.getIsolateID
method.
dart:ffi
#- Changed
NativeCallable.nativeFunction
so calls now throw an error if the receiver is already closed, instead of returningnullptr
.
dart:io
#- Eliminated trailing whitespace from HTTP headers.
- Inserted a space at the fold point of folded header values that
HttpClientResponse.headers
andHttpRequest.headers
return.
dart:js_interop
#- Experimental Removed
JSNumber.toDart
in favor oftoDartDouble
andtoDartInt
. - Experimental Removed
Object.toJS
in favor ofObject.toJSBox.
- Experimental Restricted external JS interop APIs using
dart:js_interop
to a set of allowed types. - Experimental Prohibited use of
isNull
andisUndefined
on dart2wasm. - Experimental Changed
typeofEquals
andinstanceof
APIs to both return bool instead ofJSBoolean
. Also,typeofEquals
now takesString
instead ofJSString
. - Experimental Changed
JSAny
andJSObject
types to only implementable, not extendable, by user@staticInterop
types. - Experimental Changed
JSArray.withLength
to takeint
instead ofJSNumber
.
Tools
#Development JavaScript compiler (DDC)
#- Added interceptors for JavaScript
Symbol
andBigInt
types; they should no longer be used withpackage:js
classes.
Production JavaScript compiler (dart2js)
#- Added interceptors for JavaScript
Symbol
andBigInt
types; they should no longer be used withpackage:js
classes.
Analyzer
#Language versioned Private final field promotion might cause the following analyzer warnings to trigger on existing code that previously passed analysis:
dartclass C { final num? _x = null; void test() { if (_x != null) { print(_x! * 2); // unnecessary_non_null_assertion print(_x?.abs()); // invalid_null_aware_operator } if (_x is int) { print((_x as int).bitLength); // unnecessary_cast } } }
3.1.0
#Libraries
#dart:async
#- Added
interface
modifier to purely abstract classes:MultiStreamController
,StreamConsumer
,StreamIterator
andStreamTransformer
.
dart:io
#- Added
sameSite
to theCookie
class, and added the classSameSite
. FileSystemEvent
issealed
. This meansFileSystemEvent
cannot be extended or implemented.
dart:js_interop
#- Experimental Removed
ObjectLiteral
; create an object literal with no named members using{}.jsify()
.
package:js
#external
@staticInterop
members andexternal
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.external
@staticInterop
members andexternal
extension members will generate slightly different JS code for methods that have optional parameters.
3.0.0
#Language
#Language versioned Changed interpretation of switch cases from constant expressions to patterns.
Language versioned Class declarations from libraries that have been upgraded to Dart 3.0 can no longer be used as mixins by default.
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.
Libraries
#- The following existing classes have been made mixin classes:
Iterable
,IterableMixin
,IterableBase
,ListMixin
,SetMixin
,MapMixin
,LinkedListEntry
,StringConversionSink
.
dart:core
#- Deprecated Deprecated APIs.
dart:async
#- Removed Removed the deprecated
DeferredLibrary
class.
dart:collection
#- Language versioned Changes to platform libraries.
dart:developer
#- Removed Removed the deprecated
MAX_USER_TAGS
constant. UsemaxUserTags
instead. - Removed Removed the deprecated
Metrics
,Metric
,Counter
, andGauge
classes as they have been broken since Dart 2.0.
dart:ffi
#- Experimental Deprecated The
@FfiNative
annotation is now deprecated. Usages should be updated to use the@Native
annotation.
dart:html
#- Removed Removed the deprecated
registerElement
andregisterElement2
methods inDocument
andHtmlDocument
.
dart:math
#- Language versioned The
Random
interface can only be implemented, not extended.
dart:io
#- Updated
NetworkProfiling
to accommodate newString
ids that are introduced in vm_service:11.0.0
2.19.0
#Language
#- Flagged additional code as unreachable due to types
Null
andNever
. - Don't delegate inaccessible private names to
noSuchMethod
. - Report a compile-time error for all cyclic dependencies during top-level type inference.
Libraries
#dart:convert
#- Removed The previously deprecated API [
DEFAULT_BUFFER_SIZE
] inJsonUtf8Encoder
has been removed.
dart:developer
#- Removed Removed previously deprecated APIs
kInvalidParams
,kExtensionError
,kExtensionErrorMax
, andkExtensionErrorMin
inServiceExtensionResponse
.
dart:ffi
#- Changed the runtime type argument of
Pointer
toNever
in preparation of completely removing the runtime type argument. ChangedPointer.toString
to not report any type argument.
dart:io
#- Disallow negative or hexadecimal content-length headers.
File.create
now takes new optionalexclusive
bool
parameter, and when it istrue
the operation will fail if target file already exists.- Calling
ResourceHandle.toFile()
,ResourceHandle.toSocket()
,ResourceHandle.toRawSocket()
orResourceHandle.toRawDatagramSocket()
, more than once now throws aStateError
.
dart:isolate
#- Reverted
SendPort.send
back to strict checks on contents of messages when sending messages between isolates that are not known to share the same code.
dart:mirrors
#- Removed Removed APIs
MirrorsUsed
andComment
.
package:js
#- Breaking changes to the preview feature
@staticInterop
:- Disallowed classes with this annotation from using
external
generative constructors. See 48730 and 49941 for more details. - Disallowed classes with this annotation's external extension members from using type parameters.
- Classes with this annotation should also have the
@JS
annotation. - Classes with this annotation can not be implemented by classes without this annotation.
- Disallowed classes with this annotation from using
dart2js
#2.18.0
#Language
#Libraries
#dart:io
#- Changed the
uri
property ofRedirectException
indart:io
to be nullable. - Removed constants in
dart:io
networking APIs following theSCREAMING_CAPS
convention. - The Dart VM no longer automatically restores the initial terminal settings upon exit.
Tools
#Dart command line
#2.17.0
#Libraries
#dart:io
#- Added new
connectionFactory
property toHttpClient
. - Added new
keyLog
property toHttpClient
, which allows TLS keys to be logged for debugging purposes. - Removed constants in
dart:io
following theSCREAMING_CAPS
- Added a new
allowLegacyUnsafeRenegotiation
property toSecurityContext
, which allows TLS renegotiation for client secure sockets.
Tools
#Dart command line
#- Deprecated Deprecated the standalone
dart2js
tool. - Deprecated Deprecated the standalone
dartdevc
tool. - Removed Removed the standalone
dartdoc
tool.
2.16.0
#Libraries
#dart:io
#- On Windows,
Directory.rename
will no longer delete a directory ifnewPath
specifies one. Instead, aFileSystemException
will be thrown. - Removed Removed the
Platform.packageRoot
API.
dart:isolate
#- Removed Removed the
Isolate.packageRoot
API.
Tools
#Dart command line
#- Deprecated Deprecated the standalone
dartanalyzer
tool. - Deprecated Deprecated the standalone
dartdoc
tool. - Removed Removed the deprecated standalone
pub
tool.
2.15.0
#Libraries
#dart:io
#- Updated the
SecurityContext
class to set the minimum TLS protocol version to TLS1_2_VERSION (1.2) instead of TLS1_VERSION.
dart:web_sql
#dart:html
#- Removed
window.openDatabase
(related todart:web_sql
deletion above).
Tools
#Dart command line
#- Removed the standalone
dart2native
tool. - Removed the standalone
dartfmt
tool.
Dart VM
#- Removed support for
dart-ext:
-style native extensions - Grouped isolates spawned via the
Isolate.spawn()
API to operate on the same managed heap, and therefore share various VM-internal data structures.
2.14.0
#Libraries
#dart:io
#- The setter callbacks
.authenticate
and.authenticateProxy
inHttpClient
must now accept a nullablerealm
argument (for pre-migrated null safe code).
dart:typed_data
#- Most types exposed by this library can no longer be extended, implemented or mixed-in.
Tools
#Dart VM
#- Expandos, and the
object
parameters ofDart_NewWeakPersistentHandle
andDart_NewFinalizableHandle
, no longer acceptPointer
and subtypes ofStruct
Dart command line
#- Deprecated the standalone
dart2native
tool - Deprecated the standalone
dartfmt
tool.
dart2js
#dart2js
no longer supports legacy browsers, because it emits ES6+ JavaScript by default.
Dart Dev Compiler (DDC)
#- Changed subtyping relations of
package:js
classes to be more correct and consistent with Dart2JS.
2.13.0
#Libraries
#package:js
#- No longer valid to use a
String
that matches an@Native
annotation in an@JS()
annotation for a non-anonymous JS interop class.
2.12.0
#Language
#- Null safety is now enabled by default in all code that has not opted out.
- Fixed an implementation bug where
this
would sometimes undergo type promotion in extensions.
Libraries
#dart:ffi
#- Deprecated invocations with a generic
T
ofsizeOf<T>
,Pointer<T>.elementAt()
,Pointer<T extends Struct>.ref
, andPointer<T extends Struct>[]
- Deprecated
allocate
inpackage:ffi
, as it will no longer be able to invokesizeOf<T>
generically. - Deprecated subtypes of
Struct
without any native member.
Tools
#Dart VM
#Dart_WeakPersistentHandle
no longer auto-deletes itself when the referenced object is garbage collected to avoid race conditions.- Renamed
Dart_WeakPersistentHandleFinalizer
toDart_HandleFinalizer
and removed itshandle
argument.
Pub
#2.10.0
#Tools
#Dart VM
#- Renamed
dart_api_dl.cc
todart_api_dl.c
and changed to a pure C file.
2.9.0
#Libraries
#dart:convert
#- When encoding a string containing unpaired surrogates as UTF-8, the unpaired surrogates will be encoded as replacement characters (
U+FFFD
). - When decoding UTF-8, encoded surrogates will be treated as malformed input.
- Changed the number of replacement characters emitted for malformed input sequences to match the WHATWG encoding standard when decoding UTF-8 with
allowMalformed: true
.
dart:html
#CssClassSet.add()
andCssClassSet.toggle
now returnfalse
instead ofnull
if theCssClassSet
corresponds to multiple elements.
dart:mirrors
#- Web compilers (dart2js and DDC) now produce a compile-time error if
dart:mirrors
is imported.
Tools
#Dart VM
#- When printing a string using the
print
function, the default implementation will print any unpaired surrogates in the string as replacement characters (U+FFFD
). - The
Dart_StringToUTF8
function in the Dart API will convert unpaired surrogates into replacement characters.
2.8.1
#Language
#- Fixed an implementation bug where local variable inference would incorrectly use the promoted type of a type variable.
- Fixed an implementation bug surrounding the clauses
implements Function
,extends Function
, orwith Function
no longer having an effect since Dart 2.0.0.
Libraries
#dart:async
#- Changed the return type of
StreamSubscription.cancel()
toFuture<void>
. - Split the
runZoned()
function into two functions:runZoned()
andrunZonedGuarded()
, where the latter has a requiredonError
parameter, and the former has none. - Errors passed to
Completer.completeError()
,Stream.addError()
,Future.error()
, etc. can no longer benull
. - Made stack traces non-null .
dart:core
#- Three members on
RuneIterator
no longer returnnull
when accessed before the first call tomoveNext()
. - The
String.fromEnvironment()
default value fordefaultValue
is now an empty string instead ofnull
. - The default value for
int.fromEnvironment()
'sdefaultValue
parameter is now zero.
dart:ffi
#- Changed
Pointer.asFunction()
andDynamicLibrary.lookupFunction()
to extension methods.
dart:io
#- Changed the signature of
HttpHeaders
methodsadd()
andset
. - The
Socket
class now throws aSocketException
if the socket has been explicitly destroyed or upgraded to a secure socket upon setting or getting socket options. - The
Process
class now throws aStateError
if the process is detached (ProcessStartMode.detached
andProcessStartMode.detachedWithStdio
) upon accessing theexitCode
getter. - The
Process
class now also throws when not connected to the child process's stdio (ProcessStartMode.detached
andProcessStartMode.inheritStdio
) upon accessing thestdin
,stdout
, andstderr
getters. - The dummy object returned if
FileStat.stat()
orFileStat.statSync()
fail now contains Unix epoch timestamps instead ofnull
for theaccessed
,changed
, andmodified
getters. - The
HeaderValue
class now parses more strictly in two invalid edge cases.
Tools
#Dart Dev Compiler (DDC)
#We fixed several inconsistencies between DDC and Dart2JS so that users less frequently encounter code that is accepted by one compiler but then fails in the other.
- Deleted the legacy (analyzer based) version of DDC.
- Functions passed to JavaScript using the recommended
package:js
interop specification must now be wrapped with a call toallowInterop
. - Constructors in
@JS()
classes must be marked withexternal
.
dart2js
#- Corresponding type parameter bounds now only need to be mutual subtypes rather than structurally equal up to renaming of bound type variables and equating all top types.
- Types are now normalized.
- Constructors in
@JS()
classes must be marked withexternal
. - Completely removed the
--package-root
flag, which was hidden and disabled in Dart 2.0.0.
2.7.1
#2.7.0
#Language
#Libraries
#dart:io
#- Added
IOOverrides.serverSocketBind
to aid in writing tests that wish to mockServerSocket.bind
.
2.6.0
#Language
#- Changed inference when using
Null
values in aFutureOr
context. Namely, constraints of the forms similar toNull
<:FutureOr<T>
now yieldNull
as the solution forT
.
Libraries
#dart:ffi
#- The API now makes use of static extension members.
- Removed memory management
Pointer.allocate
andPointer.free
. Pointer.offsetBy
was removed, usecast
andelementAt
instead.
2.5.0
#Libraries
#- Various methods and properties across various core libraries, which used to declare a return type of
List<int>
, were updated to declare a return type ofUint8List
.
dart:io
#- The
Cookie
class's constructor'sname
andvalue
optional positional parameters are now mandatory. - The
Cookie
class'sname
andvalue
setters now validate that the strings are made from the allowed character set and are not null.
Tools
#Pub
#- Packages published to pub.dev can no longer contain git dependencies.
2.4.0
#Language
#Libraries
#dart:isolate
#Isolate.resolvePackageUri
will always throw anUnsupportedError
when compiled with dart2js or DDC.
dart:async
#- Fixed a bug in the
StreamIterator
class whereawait for
allowednull
as a stream.
2.2.0
#Libraries
#package:kernel
#- The
klass
getter on theInstanceConstant
class in the Kernel AST API has been renamed toclassNode
for consistency. - Updated
Link
implementation to utilize true symbolic links instead of junctions on Windows.
2.1.1
#Libraries
#dart:io
#Tools
#Dart VM
#- Fixed a soundness hole when using
dart:mirrors
to reflectively invoke a method in an incorrect way that violates its static types.
2.1.0
#Language
#- A number of static errors that should have been detected and reported were not supported in 2.0.0. These are reported now, which means existing incorrect code may show new errors:
- Mixins must correctly override their superclasses.
- Implicit type arguments in extends clauses must satisfy the class bounds.
- Instance members should shadow prefixes.
- Constructor invocations must use valid syntax, even with optional
new
. - Type arguments to generic typedefs must satisfy their bounds.
- Classes can't implement FutureOr.
- Abstract methods may not unsoundly override a concrete method.
- Constant constructors cannot redirect to non-constant constructors.
- Setters with the same name as the enclosing class aren't allowed.
Tools
#dart2js
#- Duplicate keys in a const map are not allowed and produce a compile-time error.
2.0.0
#Language
#- Replaced the unsound optional static type system with a sound static type system using type inference and runtime checks, formerly called strong mode.
- Functions marked
async
now run synchronously until the firstawait
statement.
Libraries
#- Renamed constants in the core libraries from
SCREAMING_CAPS
tolowerCamelCase
. - Added many new methods to core library classes that will need to be implemented if you implement the interfaces of these classes.
dart:isolate
anddart:mirrors
are no longer supported when using Dart for the web.
Tools
#Pub
#- Replaced pub's transformer-based build system with a new build system.
Unless stated otherwise, the documentation on this site reflects Dart 3.5.3. Page last updated on 2024-08-06. View source or report an issue.