Skip to content

Commit 276547b

Browse files
committed
feat: add factory constructors to StacBorderRadius
- Add StacBorderRadius.only() factory for individual side styling - Add StacBorderRadius.horizontal() factory for top/bottom borders only - Add StacBorderRadius.vertical() factory for left/right borders only - Add StacBorderRadius.circular() factory for uniform circular borders - Include comprehensive documentation with Dart and JSON examples
1 parent 5241e45 commit 276547b

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

packages/stac_core/lib/foundation/borders/stac_border_radius/stac_border_radius.dart

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,146 @@ class StacBorderRadius implements StacElement {
6565
bottomRight: radius,
6666
);
6767

68+
/// Creates a border radius with individual values for each corner.
69+
///
70+
/// This factory method allows you to specify different radius values
71+
/// for each corner individually.
72+
///
73+
/// {@tool snippet}
74+
/// Dart Example:
75+
/// ```dart
76+
/// StacBorderRadius.only(
77+
/// topLeft: 8.0,
78+
/// topRight: 4.0,
79+
/// bottomLeft: 4.0,
80+
/// bottomRight: 8.0,
81+
/// )
82+
/// ```
83+
/// {@end-tool}
84+
///
85+
/// {@tool snippet}
86+
/// JSON Example:
87+
/// ```json
88+
/// {
89+
/// "topLeft": 8.0,
90+
/// "topRight": 4.0,
91+
/// "bottomLeft": 4.0,
92+
/// "bottomRight": 8.0
93+
/// }
94+
/// ```
95+
/// {@end-tool}
96+
const StacBorderRadius.only({
97+
double? topLeft,
98+
double? topRight,
99+
double? bottomLeft,
100+
double? bottomRight,
101+
}) : this(
102+
topLeft: topLeft,
103+
topRight: topRight,
104+
bottomLeft: bottomLeft,
105+
bottomRight: bottomRight,
106+
);
107+
108+
/// Creates a border radius with symmetric horizontal corners.
109+
///
110+
/// This factory method creates a border radius where left corners
111+
/// have the same radius and right corners have the same radius.
112+
///
113+
/// {@tool snippet}
114+
/// Dart Example:
115+
/// ```dart
116+
/// StacBorderRadius.horizontal(
117+
/// left: 8.0,
118+
/// right: 4.0,
119+
/// )
120+
/// ```
121+
/// {@end-tool}
122+
///
123+
/// {@tool snippet}
124+
/// JSON Example:
125+
/// ```json
126+
/// {
127+
/// "topLeft": 8.0,
128+
/// "topRight": 4.0,
129+
/// "bottomLeft": 8.0,
130+
/// "bottomRight": 4.0
131+
/// }
132+
/// ```
133+
/// {@end-tool}
134+
const StacBorderRadius.horizontal({double? left, double? right})
135+
: this(
136+
topLeft: left,
137+
topRight: right,
138+
bottomLeft: left,
139+
bottomRight: right,
140+
);
141+
142+
/// Creates a border radius with symmetric vertical corners.
143+
///
144+
/// This factory method creates a border radius where top corners
145+
/// have the same radius and bottom corners have the same radius.
146+
///
147+
/// {@tool snippet}
148+
/// Dart Example:
149+
/// ```dart
150+
/// StacBorderRadius.vertical(
151+
/// top: 8.0,
152+
/// bottom: 4.0,
153+
/// )
154+
/// ```
155+
/// {@end-tool}
156+
///
157+
/// {@tool snippet}
158+
/// JSON Example:
159+
/// ```json
160+
/// {
161+
/// "topLeft": 8.0,
162+
/// "topRight": 8.0,
163+
/// "bottomLeft": 4.0,
164+
/// "bottomRight": 4.0
165+
/// }
166+
/// ```
167+
/// {@end-tool}
168+
const StacBorderRadius.vertical({double? top, double? bottom})
169+
: this(
170+
topLeft: top,
171+
topRight: top,
172+
bottomLeft: bottom,
173+
bottomRight: bottom,
174+
);
175+
176+
/// Creates a circular border radius.
177+
///
178+
/// This factory method creates a border radius that forms a perfect circle
179+
/// when applied to a square widget. For non-square widgets, it creates
180+
/// an elliptical shape.
181+
///
182+
/// {@tool snippet}
183+
/// Dart Example:
184+
/// ```dart
185+
/// StacBorderRadius.circular(20.0)
186+
/// ```
187+
/// {@end-tool}
188+
///
189+
/// {@tool snippet}
190+
/// JSON Example:
191+
/// ```json
192+
/// {
193+
/// "topLeft": 20.0,
194+
/// "topRight": 20.0,
195+
/// "bottomLeft": 20.0,
196+
/// "bottomRight": 20.0
197+
/// }
198+
/// ```
199+
/// {@end-tool}
200+
const StacBorderRadius.circular(double radius)
201+
: this(
202+
topLeft: radius,
203+
topRight: radius,
204+
bottomLeft: radius,
205+
bottomRight: radius,
206+
);
207+
68208
/// The radius for the top-left corner in logical pixels.
69209
///
70210
/// If null, no radius will be applied to this corner.

0 commit comments

Comments
 (0)