Deprecated API removed after v3.13
Summary
#In accordance with Flutter's Deprecation Policy, deprecated APIs that reached end of life after the 3.13 stable release have been removed.
All affected APIs have been compiled into this primary source to aid in migration. To further aid your migration, check out this quick reference sheet.
Changes
#This section lists the deprecations by the package and affected class.
Chip classes' useDeleteButtonTooltip
#Package: flutter Supported by Flutter Fix: yes
The useDeleteButtonTooltip
property of the following classes was deprecated
in v2.10:
DeletableChipAttributes
Chip
RawChip
InputChip
deleteButtonTooltipMessage
replaces useDeleteButtonTooltip
. This change simplified the
API, as providing an empty String to deleteButtonTooltipMessage
achieves the
same result as setting the original property useDeleteButtonTooltip
to false.
When deleteButtonTooltipMessage
is unset, the
MaterialLocalizations.deleteButtonTooltip
is used by default.
The Deprecate useDeleteButtonTooltip
for Chips design document
covers this update to chips and tooltips in greater depth.
To learn more, check out the chips and tooltips migration guide.
Migration guide
Code before migration:
Chip(useDeleteButtonTooltip: false);
InputChip(useDeleteButtonTooltip: true);
RawChip rawChip = RawChip();
rawChip.useDeleteButtonTooltip;
Code after migration:
Chip(deleteButtonTooltipMessage: '');
InputChip();
RawChip rawChip = RawChip();
rawChip.deleteButtonTooltipMessage;
References
API documentation:
Relevant PRs:
MaterialButtonWithIconMixin
#Package: flutter Supported by Flutter Fix: no
The MaterialButtonWithIconMixin
property was deprecated in v2.11.
With the introduction of new button classes TextButton
, OutlinedButton
and ElevatedButton
,
this mixin is no longer used.
An earlier release removed old button classes that used this mixin.
As a result, this mixin no longer affects any classes that might mix it in.
Migration guide
Code before migration:
class MyButtonClass extends StatelessWidget with MaterialButtonWithIconMixin {
// ...
}
Code after migration:
class MyButtonClass extends StatelessWidget {
// ...
}
References
Relevant PRs:
PlatformsViewsService.synchronizeToNativeViewHierarchy
#Package: flutter Supported by Flutter Fix: no
The static method synchronizeToNativeViewHierarchy
of PlatformsViewsService
was deprecated in v2.11.
During the deprecation period, the method was a no-op function as it was no longer required to call for performance improvements. References to the method should be removed and won't impact the application.
Migration guide
Code before migration:
await PlatformsViewsService.synchronizeToNativeViewHierarchy(false);
Code after migration:
References
API documentation:
Relevant PRs:
TextSelectionOverlay.fadeDuration
#Package: flutter Supported by Flutter Fix: yes
The static fadeDuration
property of TextSelectionOverlay
was deprecated
in v2.12.
The SelectionOverlay.fadeDuration
property replaces TextSelectionOverlay.fadeDuration
.
With the TextSelectionOverlay
refactor,
SelectionOverlay
was added as a more generic widget without
the specific dependency on RenderEditable
.
Migration guide
Code before migration:
TextSelectionOverlay.fadeDuration;
Code after migration:
SelectionOverlay.fadeDuration;
References
API documentation:
Relevant PRs:
androidOverscrollIndicator
#Package: flutter Supported by Flutter Fix: no
The androidOverscrollIndicator
property of the following classes was
deprecated in v2.13:
ScrollBehavior
MaterialScrollBehavior
ThemeData
This flag was introduced to allow users to configure scrolling widgets to use
the GlowingOverscrollIndicator
or the StretchingOvercrollIndicator
.
It was deprecated in favor of the ThemeData.useMaterial3
flag
as the framework introduced more support for Material 3-styled widgets.
Since ThemeData.useMaterial3
is true
by default,
the StretchingOverscrollIndicator
is applied by default.
Setting this value to false
will apply a GlowingOverscrollIndicator
instead.
Alternatively, the buildOverscrollIndicator
method of ScrollBehavior
or
MaterialScrollBehavior
can be overridden to further alter the appearance of
overscroll indicators.
Migration guide
Code before migration:
MaterialApp(
scrollBehavior: MaterialScrollBehavior(
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
),
//...
);
MaterialApp(
scrollBehavior: ScrollBehavior(
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
),
//...
);
MaterialApp(
theme: Theme.light().copyWith(
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
),
//...
);
Code after migration:
MaterialApp(
theme: Theme.light().copyWith(
// defaults to true and stretching indicator,
// false results in glowing indicator
useMaterial3: false,
),
//...
);
References
API documentation:
ScrollBehavior
MaterialScrollBehavior
ThemeData
GlowingOverscrollIndicator
StretchingOverscrollIndicator
Relevant PRs:
Updates to ImageProvider and PaintingBinding
#Package: flutter Supported by Flutter Fix: no
The instantiateImageCodec
method of PaintingBinding
, as well as the load
method of ImageProvider
and the associated DecoderCallback
were all
deprecated in v2.13.
The respective replacements are:
Deprecated Method | Current Method |
---|---|
PaintingBinding.instantiateImageCodec |
PaintingBinding.instantiateImageCodecFromBuffer |
ImageProvider.load |
ImageProvider.loadBuffer |
DecoderCallback |
DecoderBufferCallback |
This change enabled faster performance in image loading by using a buffer.
Migration guide
Code before migration:
PaintingBinding.instance.instantiateImageCodec
Code after migration:
PaintingBinding.instance.instantiateImageCodecFromBuffer
References
API documentation:
Relevant PRs:
TestWindow properties
#Package: flutter_test Supported by Flutter Fix: no
To prepare for multi-window support,
many deprecated properties of TestWindow
have been removed.
While TestWindow
has been deprecated, it does not qualify
for removal at this time.
Migrating the expired properties now will help in migrating from TestWindow
.
The following properties were removed:
localeTestValue
clearLocaleTestValue
localesTestValue
clearLocalesTestValue
initialLifecycleStateTestValue
textScaleFactorTestValue
clearTextScaleFactorTestValue
platformBrightnessTestValue
clearPlatformBrightnessTestValue
alwaysUse24HourFormatTestValue
clearAlwaysUse24HourTestValue
brieflyShowPasswordTestValue
defaultRouteNameTestValue
clearDefaultRouteNameTestValue
semanticsEnabledTestValue
clearSemanticsEnabledTestValue
accessibilityFeaturesTestValue
clearAccessibilityFeaturesTestValue
To learn more about this TestWindow
update, check out
TestWindow
migration guide.
Migration guide
Code before migration:
testWidgets('My test', (WidgetTester tester) aysnc {
// For all instances, replace window with platformDispatcher
tester.binding.window.textScaleFactorTestValue = 42;
addTearDown(tester.binding.window.clearTextScaleFactorTestValue);
// ...
});
Code after migration:
testWidgets('My test', (WidgetTester tester) aysnc {
// For all instances, replace window with platformDispatcher
tester.binding.platformDispatcher.textScaleFactorTestValue = 42;
addTearDown(tester.binding.platformDispatcher.clearTextScaleFactorTestValue);
// ...
});
References
API documentation:
Relevant PRs:
Timeline
#除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-10-09。 查看文档源码 或者 为本页面内容提出建议。