New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create migration guide for BoxDecoration.shape #7704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
title: Migration guide for BoxDecoration.circle | ||
description: Removal of BoxDecoration.circle and how to migrate | ||
--- | ||
|
||
## Summary | ||
|
||
The `shape` parameter of `BoxDecoration` has been deprecated. Existing uses | ||
of `BoxDecoration(shape: BoxShape.circle)` should use | ||
`ShapeDecoration(shape: CircleBorder())` instead. | ||
|
||
## Context | ||
|
||
The enum property `BoxShape shape` from `BoxDecoration` has been deprecated, | ||
as increasing the number of supported shapes through enums created | ||
unnecessary complexity and performance costs. | ||
Users should migrate to use `ShapeDecoration` in conjunction with | ||
`ShapeBorder`, the replacement for `BoxShape`. | ||
|
||
## Description of change | ||
|
||
Remove `BoxDecoration(shape: BoxShape.circle)` and `BoxDecoration.shape`. | ||
|
||
- Replace `BoxDecoration(shape: BoxShape.circle)` with | ||
`ShapeDecoration(shape: CircleBorder())`. | ||
- Remove the `BoxDecoration.shape` property from | ||
`BoxDecoration(shape: BoxShape.rectangle)`. | ||
bernaferrari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Migration guide | ||
|
||
When you use `Border`, | ||
`CircleBorder(width: ..., color: ..., strokeAlign: ...)` inherits | ||
the `Border.all(width: ..., color: ..., strokeAlign: ...)` values. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure where this fits into the context of this guide. Can you explain more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have |
||
|
||
Code before migration: | ||
|
||
<!-- skip --> | ||
```dart | ||
BoxDecoration( | ||
shape: BoxShape.circle, | ||
) | ||
|
||
BoxDecoration( | ||
shape: BoxShape.circle, | ||
border: Border.all(width: 20, color: Colors.red), | ||
boxShadow: [], | ||
) | ||
|
||
BoxDecoration( | ||
shape: BoxShape.rectangle, | ||
) | ||
``` | ||
|
||
Code after migration: | ||
|
||
<!-- skip --> | ||
```dart | ||
ShapeDecoration( | ||
border: CircleBorder(), | ||
) | ||
|
||
ShapeDecoration( | ||
border: CircleBorder(width: 20, color: Colors.red), | ||
shadows: [], | ||
) | ||
|
||
BoxDecoration() | ||
``` | ||
|
||
## Timeline | ||
|
||
Landed in version: TBD<br> | ||
In stable release: not yet | ||
|
||
## References | ||
|
||
{% include docs/master-api.md %} | ||
|
||
API documentation: | ||
|
||
* [`BoxDecoration` stable][] | ||
* [`BoxDecoration` main][] | ||
|
||
Relevant issues: | ||
|
||
* [Deprecate `BoxDecoration.shape` issue][] | ||
|
||
Relevant PRs: | ||
|
||
* [Deprecate `BoxDecoration.shape` PR][] | ||
|
||
<!-- Stable channel link: --> | ||
[`BoxDecoration` stable]: {{site.api}}/flutter/lib/src/painting/BoxDecoration-class.html | ||
|
||
<!-- Master channel link: --> | ||
{% include docs/master-api.md %} | ||
|
||
[`BoxDecoration` main]: {{site.master-api}}/flutter/lib/src/painting/BoxDecoration-class.html | ||
|
||
[Deprecate `BoxDecoration.shape` issue]: {{site.repo.flutter}}/issues/108051 | ||
[Deprecate `BoxDecoration.shape` PR]: {{site.repo.flutter}}/pull/108052 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should the user replace it with? Are there other cases of using
BoxShape
that users may need to migrate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because we are not changing InkWell.