Deprecated API removed after v3.7
Summary
#In accordance with Flutter's Deprecation Policy, deprecated APIs that reached end of life after the 3.7 stable release have been removed.
All affected APIs have been compiled into this primary source to aid in migration. A quick reference sheet is available as well.
Changes
#This section lists the deprecations, listed by the affected class.
GestureRecognizer.kind
& subclasses
#Supported by Flutter Fix: yes
GestureRecognizer.kind
was deprecated in v2.3.
Use GestureRecognizer.supportedDevices
instead.
This same change affects all subclasses of GestureRecognizer
:
EagerGestureRecognizer
ForcePressGestureRecognizer
LongPressGestureRecognizer
DragGestureRecognizer
VerticalDragGestureRecognizer
HorizontalDragGestureRecognizer
MultiDragGestureRecognizer
ImmediateMultiDragGestureRecognizer
HorizontalMultiDragGestureRecognizer
VerticalMultiDragGestureRecognizer
DelayedMultiDragGestureRecognizer
DoubleTapGestureRecognizer
MultiTapGestureRecognizer
OneSequenceGestureRecognizer
PrimaryPointerGestureRecognizer
ScaleGestureRecognizer
This change allowed for multiple devices to be recognized for a gesture, rather
than the single option kind
provided.
Migration guide
Code before migration:
var myRecognizer = GestureRecognizer(
kind: PointerDeviceKind.mouse,
);
Code after migration:
var myRecognizer = GestureRecognizer(
supportedDevices: <PointerDeviceKind>[ PointerDeviceKind.mouse ],
);
References
API documentation:
GestureRecognizer
EagerGestureRecognizer
ForcePressGestureRecognizer
LongPressGestureRecognizer
DragGestureRecognizer
VerticalDragGestureRecognizer
HorizontalDragGestureRecognizer
MultiDragGestureRecognizer
ImmediateMultiDragGestureRecognizer
HorizontalMultiDragGestureRecognizer
VerticalMultiDragGestureRecognizer
DelayedMultiDragGestureRecognizer
DoubleTapGestureRecognizer
MultiTapGestureRecognizer
OneSequenceGestureRecognizer
PrimaryPointerGestureRecognizer
ScaleGestureRecognizer
Relevant PRs:
ThemeData
accentColor
, accentColorBrightness
, accentColorTextTheme
, accentColorIconTheme
, and buttonColor
#Supported by Flutter Fix: yes
The accentColor
, accentColorBrightness
, accentColorTextTheme
,
accentColorIconTheme
, and buttonColor
properties of ThemeData
were
deprecated in v2.3.
This change better aligned ThemeData
with Material Design guidelines. It also
created more clarity in theming by relying either on the core color scheme or
individual component themes for desired styling.
The accentColorBrightness
, accentColorTextTheme
,
accentColorIconTheme
, and buttonColor
are no longer used by the framework.
References should be removed.
Uses of ThemeData.accentColor
should be replaced with
ThemeData.colorScheme.secondary
.
Migration guide
#Code before migration:
var myTheme = ThemeData(
//...
accentColor: Colors.blue,
//...
);
var color = myTheme.accentColor;
Code after migration:
var myTheme = ThemeData(
//...
colorScheme: ColorScheme(
//...
secondary:Colors.blue,
//...
),
//...
);
var color = myTheme.colorScheme.secondary;
References
API documentation:
Relevant issues:
Relevant PRs:
Deprecated in:
Removed in:
AppBar
, SliverAppBar
, and AppBarTheme
updates
#Supported by Flutter Fix: yes
In v2.4, several changes were made ot the app bar classes and their themes to better align with Material Design. Several properties were deprecated at that time and have been removed.
For AppBar
, SliverAppBar
and AppBarTheme
:
brightness
has been removed, and is replaced bysystemOverlayStyle
textTheme
has been removed, and is replaced by eithertoolbarTextStyle
ortitleTextStyle
.backwardsCompatibility
can be removed, as it was a temporary migration flag for these properties.
Additionally, AppBarTheme.color
was removed, with AppBarTheme.backgroundColor
as its replacement.
Migration guide
Code before migration:
var toolbarTextStyle = TextStyle(...);
var titleTextStyle = TextStyle(...);
AppBar(
brightness: Brightness.light,
textTheme: TextTheme(
bodyMedium: toolbarTextStyle,
titleLarge: titleTextStyle,
)
backwardsCompatibility: true,
);
AppBarTheme(color: Colors.blue);
Code after migration:
var toolbarTextStyle = TextStyle(...);
var titleTextStyle = TextStyle(...);
AppBar(
systemOverlayStyle: SystemOverlayStyle(statusBarBrightness: Brightness.light),
toolbarTextStyle: toolbarTextStyle,
titleTextStyle: titleTextStyle,
);
AppBarTheme(backgroundColor: Colors.blue);
References
API documentation:
Relevant issues:
Deprecated in:
Removed in:
SystemChrome.setEnabledSystemUIOverlays
#Supported by Flutter Fix: yes
In v2.3, SystemChrome.setEnabledSystemUIOVerlays
, the static method for
setting device system level overlays like status and navigation bars, was
deprecated in favor of SystemChrome.setEnabledSystemUIMode
.
This change allowed for setting up common fullscreen modes that match native Android app designs like edge to edge.
Manually setting overlays, instead of choosing a specific mode, is still
supported through SystemUiMode.manual
, allowing developers to pass the same
list of overlays as before.
Migration guide
Code before migration:
SystemChrome.setEnabledSystemUIOverlays(<SystemUiOverlay>[
SystemUiOverlay.top,
SystemUiOverlay.bottom,
]);
Code after migration:
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: <SystemUiOverlay>[
SystemUiOverlay.top,
SystemUiOverlay.bottom,
],
);
References
API documentation:
Relevant issues:
Deprecated in:
Removed in:
SystemNavigator.routeUpdated
#Supported by Flutter Fix: yes
In v2.3, SystemNavigator.routeUpdated
was deprecated in favor of
SystemNavigator.routeInformationUpdated
.
Instead of having two ways to update the engine about the current route, the
change moved everything to one API, which separately selects the single-entry
history mode if a Navigator
that reports routes is created.
Migration guide
Code before migration:
SystemNavigator.routeUpdated(routeName: 'foo', previousRouteName: 'bar');
Code after migration:
SystemNavigator.routeInformationUpdated(location: 'foo');
References
API documentation:
Relevant issues:
Deprecated in:
Removed in:
AnimatedSize.vsync
#Supported by Flutter Fix: yes
In v2.2, AnimatedSize.vsyc
was deprecated. This property was no longer
necessary after AnimatedSize
was converted to a StatefulWidget
whose State
mixed in SingleTickerProviderStateMixin
. The change was made to fix a memory
leak.
Uses of vsync
should be removed, as AnimatedSize
now handles this property.
Migration guide
Code before migration:
AnimatedSize(
vsync: this,
// ...
);
Code after migration:
AnimatedSize(
// ...
);
References
API documentation:
Deprecated in:
Removed in:
Timeline
#除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-06-01。 查看文档源码 或者 为本页面内容提出建议。