Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
>=2.18.4 <3.0.0
-><4.0.0
Release Notes
dart-lang/sdk (dart)
v3.0.7
Compare Source
v3.0.6
Compare Source
v3.0.5
Compare Source
v3.0.4
Compare Source
This is a patch release that:
(issue #52480).
ListFactorySpecializer
during Flutter web builds (issue #52403).v3.0.3
Compare Source
This is a patch release that:
interface
modifiers on the purely abstract classesMultiStreamController
,StreamConsumer
,StreamIterator
andStreamTransformer
(#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:
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.
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: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.