Deprecated API removed after v3.3
Summary
#In accordance with Flutter's Deprecation Policy, deprecated APIs that reached end of life after the 3.3 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.
RenderUnconstrainedBox
#Supported by Flutter Fix: no
RenderUnconstrainedBox
was deprecated in v2.1. Use RenderConstraintsTransformBox
instead.
Where unconstrained in both axes, provide ConstraintsTransformBox.unconstrained
to constraintsTransform
.
If RenderUnconstrainedBox.constrainedAxis
was previously set, replace respectively:
- Where
constrainedAxis
was previouslyAxis.horizontal
, setconstraintsTransform
toConstraintsTransformBox.widthUnconstrained
. - Where
constrainedAxis
was previouslyAxis.vertical
, setconstraintsTransform
toConstraintsTransformBox.heightUnconstrained
.
This change allowed for the introduction of several more types of constraint transformations through ConstraintsTransformBox
. Other parameters of the old API are compatible with the new API.
Migration guide
Code before migration:
// Unconstrained
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
textDirection: TextDirection.ltr,
child: RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(height: 200.0),
),
alignment: Alignment.center,
);
// Constrained in horizontal axis
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
constrainedAxis: Axis.horizontal,
textDirection: TextDirection.ltr,
child: RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0),
),
alignment: Alignment.center,
);
// Constrained in vertical axis
final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox(
constrainedAxis: Axis.vertical,
textDirection: TextDirection.ltr,
child: RenderFlex(
direction: Axis.vertical,
textDirection: TextDirection.ltr,
children: <RenderBox>[flexible],
),
alignment: Alignment.center,
);
Code after migration:
// Unconstrained
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
constraintsTransform: ConstraintsTransformBox.unconstrained,
textDirection: TextDirection.ltr,
child: RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(height: 200.0),
),
alignment: Alignment.center,
);
// Constrained in horizontal axis
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
constraintsTransform: ConstraintsTransformBox.widthUnconstrained,
textDirection: TextDirection.ltr,
child: RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0),
),
alignment: Alignment.center,
);
// Constrained in vertical axis
final RenderConstraintsTransformBox unconstrained = RenderConstraintsTransformBox(
constraintsTransform: ConstraintsTransformBox.widthUnconstrained,
textDirection: TextDirection.ltr,
child: RenderFlex(
direction: Axis.vertical,
textDirection: TextDirection.ltr,
children: <RenderBox>[flexible],
),
alignment: Alignment.center,
);
References
API documentation:
Relevant PRs:
DragAnchor
, Draggable.dragAnchor
& LongPressDraggable.dragAnchor
#Supported by Flutter Fix: yes
The enum DragAnchor
, and its uses in Draggable.dragAnchor
& LongPressDraggable.dragAnchor
were deprecated in v2.1. Use dragAnchorStrategy
instead.
This change allowed for more accurate feedback of the draggable widget when used in conjunction with other widgets like Stack
and InteractiveViewer
.
Migration guide
Code before migration:
Draggable draggable = Draggable();
draggable = Draggable(dragAnchor: DragAnchor.child);
draggable = Draggable(dragAnchor: DragAnchor.pointer);
LongPressDraggable longPressDraggable = LongPressDraggable();
longPressDraggable = LongPressDraggable(dragAnchor: DragAnchor.child);
longPressDraggable = LongPressDraggable(dragAnchor: DragAnchor.pointer);
Code after migration:
Draggable draggable = Draggable();
draggable = Draggable(dragAnchorStrategy: childDragAnchorStrategy);
draggable = Draggable(dragAnchorStrategy: pointerDragAnchorStrategy);
LongPressDraggable longPressDraggable = LongPressDraggable();
longPressDraggable = LongPressDraggable(dragAnchorStrategy: childDragAnchorStrategy);
longPressDraggable = LongPressDraggable(dragAnchorStrategy: pointerDragAnchorStrategy);
References
API documentation:
Relevant issues:
Relevant PRs:
ScrollBehavior.buildViewportChrome
#Supported by Flutter Fix: yes
The method ScrollBehavior.buildViewportChrome
was deprecated in v2.1.
This method was used by the Scrollable
widget to apply an overscroll indicator, like GlowingOverscrollIndicator
, by default on the appropriate platforms. As more default decorators have been added, like Scrollbar
s, each has instead been split into individual methods to replace buildViewportChrome
.
This allows extending classes to only override the specific decorator, through buildScrollbar
or buildOverscrollIndicator
, rather than needing to rewrite code in order to maintain one or the other.
Migration guide
In-depth migration guide available
Code before migration:
final ScrollBehavior scrollBehavior = ScrollBehavior();
scrollBehavior.buildViewportChrome(context, child, axisDirection);
Code after migration:
final ScrollBehavior scrollBehavior = ScrollBehavior();
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
References
Design document:
API documentation:
Relevant issues:
Relevant PRs:
Timeline
#In stable release: 3.7
Unless stated otherwise, the documentation on this site reflects the latest stable version of Flutter. Page last updated on 2024-06-01. View source or report an issue.