Breaking changes and deprecations
- Not yet released to stable
- Released in 3.2.0
- Released in 3.1.0
- Released in 3.0.0
- Released in 2.19.0
- Released in 2.18.0
- Released in 2.17.0
- Released in 2.16.0
- Released in 2.15.0
- Released in 2.14.0
- Released in 2.13.0
- Released in 2.12.0
- Released in 2.10.0
- Released in 2.9.0
- Released in 2.8.1
- Released in 2.7.1
- Released in 2.7.0
- Released in 2.6.0
- Released in 2.5.0
- Released in 2.4.0
- Released in 2.2.0
- Released in 2.1.1
- Released in 2.1.0
- Released in 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 “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 “Deprecated” and “Removed”, respectively. 
- 
    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”, possibly in conjunction with another change type. 
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.
Not yet released to stable
Libraries
dart:nativewrappers
- 
Marked classes belonging to NativeWrapperClassasbaseso that none of their subtypes can be implemented.
dart:typed_data
- Deprecated: Unmodifiable view classes for typed data.
Released in 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 waitForfunction.
dart:convert
- 
Changed return types of utf8.encode()andUtf8Codec.encode()fromList<int>toUint8List.
dart:developer
- 
Deprecated: The Service.getIsolateIDmethod.
dart:ffi
- 
Changed NativeCallable.nativeFunctionso 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.headersandHttpRequest.headersreturn.
dart:js_interop
- 
Experimental Removed: JSNumber.toDartin favor oftoDartDoubleandtoDartInt.
- 
Experimental Removed: Object.toJSin favor ofObject.toJSBox.
- 
Experimental: Restricted external JS interop APIs using dart:js_interopto a set of allowed types.
- 
Experimental: Prohibited use of isNullandisUndefinedon dart2wasm.
- 
Experimental: Changed typeofEqualsandinstanceofAPIs to both return bool instead ofJSBoolean. Also,typeofEqualsnow takesStringinstead ofJSString.
- 
Experimental: Changed JSAnyandJSObjecttypes to only implementable, not extendable, by user@staticInteroptypes.
- 
Experimental: Changed JSArray.withLengthto takeintinstead ofJSNumber.
Tools
Development JavaScript compiler (DDC)
- 
Added interceptors for JavaScript SymbolandBigInttypes; they should no longer be used withpackage:jsclasses.
Production JavaScript compiler (dart2js)
- 
Added interceptors for JavaScript SymbolandBigInttypes; they should no longer be used withpackage:jsclasses.
Analyzer
- 
    Language versioned: Private final field promotion might cause the following analyzer warnings to trigger on existing code that previously passed analysis: class 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 } } }
Released in 3.1.0
Libraries
dart:async
- 
Added interfacemodifier to purely abstract classes:MultiStreamController,StreamConsumer,StreamIteratorandStreamTransformer.
dart:io
- 
Added sameSiteto theCookieclass, and added the classSameSite.
- 
FileSystemEventissealed. This meansFileSystemEventcannot be extended or implemented.
dart:js_interop
- 
Experimental Removed: ObjectLiteral; create an object literal with no named members using{}.jsify().
package:js
- 
external@staticInteropmembers andexternalextension members can no longer be used as tear-offs. Declare a closure or a non-externalmethod that calls these members, and use that instead.
- 
external@staticInteropmembers andexternalextension members will generate slightly different JS code for methods that have optional parameters.
Released in 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 continuestatement targets a label that is not a loop (for,doandwhilestatements) or aswitchmember.
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 DeferredLibraryclass.
dart:collection
- Language versioned: Changes to platform libraries.
dart:developer
- 
Removed: Removed the deprecated MAX_USER_TAGSconstant. UsemaxUserTagsinstead.
- 
Removed: Removed the deprecated Metrics,Metric,Counter, andGaugeclasses as they have been broken since Dart 2.0.
dart:html
- 
Removed: Removed the deprecated registerElementandregisterElement2methods inDocumentandHtmlDocument.
dart:math
- 
Language versioned: The Randominterface can only be implemented, not extended.
dart:io
- 
Updated NetworkProfilingto accommodate newStringids that are introduced in vm_service:11.0.0
Released in 2.19.0
Language
- 
Flagged additional code as unreachable due to types NullandNever.
- 
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] inJsonUtf8Encoderhas been removed.
dart:developer
- 
Removed: Removed previously deprecated APIs kInvalidParams,kExtensionError,kExtensionErrorMax, andkExtensionErrorMininServiceExtensionResponse.
dart:ffi
- 
Changed the runtime type argument of PointertoNeverin preparation of completely removing the runtime type argument. ChangedPointer.toStringto not report any type argument.
dart:io
- Disallow negative or hexadecimal content-length headers.
- 
File.createnow takes new optionalexclusiveboolparameter, and when it istruethe 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.sendback to strict checks on contents of messages when sending messages between isolates that are not known to share the same code.
dart:mirrors
- 
Removed APIs [MirrorsUsed] and [Comment].
package:js
- Breaking changes to the preview feature @staticInterop:- Disallowed classes with this annotation from using externalgenerative 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 @JSannotation.
- Classes with this annotation can not be implemented by classes without this annotation.
 
- Disallowed classes with this annotation from using 
dart2js
Released in 2.18.0
Language
Libraries
dart:io
- 
Changed the uriproperty ofRedirectExceptionindart:ioto be nullable.
- 
Removed constants in dart:ionetworking APIs following theSCREAMING_CAPSconvention.
- The Dart VM no longer automatically restores the initial terminal settings upon exit.
Tools
Dart command line
Released in 2.17.0
Libraries
dart:io
- 
Added new connectionFactoryproperty toHttpClient.
- 
Added new keyLogproperty toHttpClient, which allows TLS keys to be logged for debugging purposes.
- Removed constants in dart:iofollowing theSCREAMING_CAPS
- 
Added a new allowLegacyUnsafeRenegotiationproperty toSecurityContext, which allows TLS renegotiation for client secure sockets.
Tools
Dart command line
- 
Deprecated: Deprecated the standalone dart2jstool.
- 
Deprecated: Deprecated the standalone dartdevctool.
- 
Removed: Removed the standalone dartdoctool.
Released in 2.16.0
Libraries
dart:io
- On Windows, Directory.renamewill no longer delete a directory ifnewPathspecifies one. Instead, aFileSystemExceptionwill be thrown.
- 
Removed: Removed the Platform.packageRootAPI.
dart:isolate
- 
Removed: Removed the Isolate.packageRootAPI.
Tools
Dart command line
- 
Deprecated: Deprecated the standalone dartanalyzertool.
- 
Deprecated: Deprecated the standalone dartdoctool.
- 
Removed: Removed the deprecated standalone pubtool.
Released in 2.15.0
Libraries
dart:io
- 
Updated the SecurityContextclass 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_sqldeletion above).
Tools
Dart command line
- 
Removed the standalone dart2nativetool.
- Removed the standalone dartfmttool.
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.
Released in 2.14.0
Libraries
dart:io
- The setter callbacks .authenticateand.authenticateProxyinHttpClientmust now accept a nullablerealmargument (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 objectparameters ofDart_NewWeakPersistentHandleandDart_NewFinalizableHandle, no longer acceptPointerand subtypes ofStruct
Dart command line
- Deprecated the standalone dart2nativetool
- Deprecated the standalone dartfmttool.
dart2js
- 
dart2jsno longer supports legacy browsers, because it emits ES6+ JavaScript by default.
Dart Dev Compiler (DDC)
- 
Changed subtyping relations of package:jsclasses to be more correct and consistent with Dart2JS.
Released in 2.13.0
Libraries
package:js
- 
No longer valid to use a Stringthat matches an@Nativeannotation in an@JS()annotation for a non-anonymous JS interop class.
Released in 2.12.0
Language
- Null safety is now enabled by default in all code that has not opted out.
- 
Fixed an implementation bug where thiswould sometimes undergo type promotion in extensions.
Libraries
dart:ffi
- 
Deprecated invocations with a generic TofsizeOf<T>,Pointer<T>.elementAt(),Pointer<T extends Struct>.ref, andPointer<T extends Struct>[]
- 
Deprecated allocateinpackage:ffi, as it will no longer be able to invokesizeOf<T>generically.
- 
Deprecated subtypes of Structwithout any native member.
Tools
Dart VM
- 
Dart_WeakPersistentHandleno longer auto-deletes itself when the referenced object is garbage collected to avoid race conditions.
- 
Renamed Dart_WeakPersistentHandleFinalizertoDart_HandleFinalizerand removed itshandleargument.
Pub
Released in 2.10.0
Tools
Dart VM
- 
Renamed dart_api_dl.cctodart_api_dl.cand changed to a pure C file.
Released in 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.togglenow returnfalseinstead ofnullif theCssClassSetcorresponds to multiple elements.
dart:mirrors
- 
Web compilers (dart2js and DDC) now produce a compile-time error if
dart:mirrorsis imported.
Tools
Dart VM
- When printing a string using the printfunction, the default implementation will print any unpaired surrogates in the string as replacement characters (U+FFFD).
- The Dart_StringToUTF8function in the Dart API will convert unpaired surrogates into replacement characters.
Released in 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 Functionno 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 requiredonErrorparameter, 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 RuneIteratorno longer returnnullwhen accessed before the first call tomoveNext().
- The String.fromEnvironment()default value fordefaultValueis now an empty string instead ofnull.
- The default value for int.fromEnvironment()’sdefaultValueparameter is now zero.
dart:ffi
- Changed Pointer.asFunction()andDynamicLibrary.lookupFunction()to extension methods.
dart:io
- 
Changed the signature of HttpHeadersmethodsadd()andset.
- 
The Socketclass now throws aSocketExceptionif the socket has been explicitly destroyed or upgraded to a secure socket upon setting or getting socket options.
- 
The Processclass now throws aStateErrorif the process is detached (ProcessStartMode.detachedandProcessStartMode.detachedWithStdio) upon accessing theexitCodegetter.
- 
The Processclass now also throws when not connected to the child process’s stdio (ProcessStartMode.detachedandProcessStartMode.inheritStdio) upon accessing thestdin,stdout, andstderrgetters.
- The dummy object returned if FileStat.stat()orFileStat.statSync()fail now contains Unix epoch timestamps instead ofnullfor theaccessed,changed, andmodifiedgetters.
- 
The HeaderValueclass 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:jsinterop 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-rootflag, which was hidden and disabled in Dart 2.0.0.
Released in 2.7.1
Released in 2.7.0
Language
Libraries
dart:io
- Added IOOverrides.serverSocketBindto aid in writing tests that wish to mockServerSocket.bind.
Released in 2.6.0
Language
- 
Changed inference when using Nullvalues in aFutureOrcontext. Namely, constraints of the forms similar toNull<:FutureOr<T>now yieldNullas the solution forT.
Libraries
dart:ffi
- The API now makes use of static extension members.
- Removed memory management Pointer.allocateandPointer.free.
- 
Pointer.offsetBywas removed, usecastandelementAtinstead.
Released in 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 Cookieclass’s constructor’snameandvalueoptional positional parameters are now mandatory.
- 
The Cookieclass’snameandvaluesetters 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.
Released in 2.4.0
Language
Libraries
dart:isolate
- 
Isolate.resolvePackageUriwill always throw anUnsupportedErrorwhen compiled with dart2js or DDC.
dart:async
- 
Fixed a bug in the StreamIteratorclass whereawait forallowednullas a stream.
Released in 2.2.0
Libraries
package:kernel
- The klassgetter on theInstanceConstantclass in the Kernel AST API has been renamed toclassNodefor consistency.
- 
Updated Linkimplementation to utilize true symbolic links instead of junctions on Windows.
Released in 2.1.1
Libraries
dart:io
Tools
Dart VM
- 
Fixed a soundness hole when using dart:mirrorsto reflectively invoke a method in an incorrect way that violates its static types.
Released in 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.
Released in 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 asyncnow run synchronously until the firstawaitstatement.
Libraries
- Renamed constants in the core libraries from SCREAMING_CAPStolowerCamelCase.
- Added many new methods to core library classes that will need to be implemented if you implement the interfaces of these classes.
- 
dart:isolateanddart:mirrorsare no longer supported when using Dart for the web.
Tools
Pub
- Replaced pub’s transformer-based build system with a new build system.