Skip to content

Commit 5241e45

Browse files
committed
feat: add .all and .symmetric factory methods to StacBorder
- Add StacBorder.all() factory method for uniform borders on all sides - Add StacBorder.symmetric() factory method for horizontal/vertical symmetric borders - Include comprehensive documentation with Dart and JSON examples for both methods - Provide convenient constructors for common border patterns
1 parent 5ab1df6 commit 5241e45

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,92 @@ class StacBorder implements StacElement {
8383
/// The left border side with individual styling.
8484
final StacBorderSide? left;
8585

86+
/// Creates a uniform border applied to all sides.
87+
///
88+
/// This factory method creates a border with the same styling applied
89+
/// to all four sides (top, right, bottom, left).
90+
///
91+
/// {@tool snippet}
92+
/// Dart Example:
93+
/// ```dart
94+
/// StacBorder.all(
95+
/// color: StacColors.blue,
96+
/// width: 2.0,
97+
/// borderStyle: StacBorderStyle.solid,
98+
/// )
99+
/// ```
100+
/// {@end-tool}
101+
///
102+
/// {@tool snippet}
103+
/// JSON Example:
104+
/// ```json
105+
/// {
106+
/// "color": "#2196F3",
107+
/// "width": 2.0,
108+
/// "borderStyle": "solid"
109+
/// }
110+
/// ```
111+
/// {@end-tool}
112+
factory StacBorder.all({
113+
StacColor? color,
114+
StacBorderStyle? borderStyle,
115+
double? width,
116+
double? strokeAlign,
117+
}) {
118+
return StacBorder(
119+
color: color,
120+
borderStyle: borderStyle,
121+
width: width,
122+
strokeAlign: strokeAlign,
123+
);
124+
}
125+
126+
/// Creates a symmetric border with different styling for horizontal and vertical sides.
127+
///
128+
/// This factory method creates a border where horizontal sides (left, right)
129+
/// have the same styling, and vertical sides (top, bottom) have the same styling.
130+
///
131+
/// {@tool snippet}
132+
/// Dart Example:
133+
/// ```dart
134+
/// StacBorder.symmetric(
135+
/// horizontal: StacBorderSide(
136+
/// color: StacColors.blue,
137+
/// width: 2.0,
138+
/// borderStyle: StacBorderStyle.solid,
139+
/// ),
140+
/// vertical: StacBorderSide(
141+
/// color: StacColors.red,
142+
/// width: 1.0,
143+
/// borderStyle: StacBorderStyle.solid,
144+
/// ),
145+
/// )
146+
/// ```
147+
/// {@end-tool}
148+
///
149+
/// {@tool snippet}
150+
/// JSON Example:
151+
/// ```json
152+
/// {
153+
/// "top": {"color": "#F44336", "width": 1.0, "borderStyle": "solid"},
154+
/// "bottom": {"color": "#F44336", "width": 1.0, "borderStyle": "solid"},
155+
/// "left": {"color": "#2196F3", "width": 2.0, "borderStyle": "solid"},
156+
/// "right": {"color": "#2196F3", "width": 2.0, "borderStyle": "solid"}
157+
/// }
158+
/// ```
159+
/// {@end-tool}
160+
factory StacBorder.symmetric({
161+
StacBorderSide? horizontal,
162+
StacBorderSide? vertical,
163+
}) {
164+
return StacBorder(
165+
top: vertical,
166+
bottom: vertical,
167+
left: horizontal,
168+
right: horizontal,
169+
);
170+
}
171+
86172
/// Creates a [StacBorder] from a JSON map.
87173
factory StacBorder.fromJson(Map<String, dynamic> json) =>
88174
_$StacBorderFromJson(json);

0 commit comments

Comments
 (0)