Smooth Corner는 Flutter 패키지로, 조정 가능한 부드러움을 가진 사각형 테두리를 만들 수 있게 해주며, Figma에서 볼 수 있는 디자인 미학을 거의 완벽하게 재현합니다. 사용자 정의 클리퍼 로직을 활용하여 위젯에 둥근 모서리나 부드럽게 곡선 처리된 가장자리를 적용하는 유연하고 성능이 우수한 방법을 제공합니다. 복잡한 이미지 자산에 의존하지 않고도 현대적이고 세련된 외관을 원하는 UI 요소에 이상적입니다. 이 패키지는 모든 주요 플랫폼을 지원하며 장치 간 일관된 렌더링을 보장합니다.
Implement smooth iOS-style rounded corners in Flutter, mimicking Figma's "corner smoothing" feature. The algorithm is also inspired by Figma's blog post "Desperately seeking squircles".
The principle involves combining two Bezier curves and an arc to create smooth corners. Similar to Figma, the smoothness is adjustable. When the smoothness parameter is 0, it represents a normal rounded rectangle, and when the parameter is 1, the rounded corners are composed of only two Bezier curves, approaching a superellipse.
You can view the debug rounded corner components and image examples I wrote in the example project, adjusting their smoothness and corner size to observe the changes in the corner curves.
Usage
Add dependency
dependencies:smooth_corner:^1.1.1
Built-in Widgets
This library provides several commonly used widgets that allow you to adjust smooth rounded corners.
All widgets provide three parameters: smoothness, side, and borderRadius, to control smooth corners and borders.
smoothness: Represents the smoothness, ranging from [0, 1.0]. According to Figma's standards, 0.6 is the closest to iOS's rounded corner curve.
side: Type is BorderSide, used to set borders.
borderRadius: Used to set the corner radius. Note that if the x and y values of the radius are not equal, the smaller one will be chosen.
SmoothContainer
SmoothContainer includes all the parameters of Container.
The smooth corner capabilities of the above widgets are implemented by SmoothRectangleBorder. You can use this ShapeBorder to freely customize your smooth corner components.