@@ -42,13 +42,13 @@ class CssBorder {
4242
4343 /// Returns `true` if all sides are unset, all radius are zero.
4444 bool get isNoOp =>
45- (_all == null || _all == CssBorderSide .none ) &&
46- (_bottom == null || _bottom == CssBorderSide .none ) &&
47- (_inlineEnd == null || _inlineEnd == CssBorderSide .none ) &&
48- (_inlineStart == null || _inlineStart == CssBorderSide .none ) &&
49- (_left == null || _left == CssBorderSide .none ) &&
50- (_right == null || _right == CssBorderSide .none ) &&
51- (_top == null || _top == CssBorderSide .none ) &&
45+ (_all? .isNoOp != false ) &&
46+ (_bottom? .isNoOp != false ) &&
47+ (_inlineEnd? .isNoOp != false ) &&
48+ (_inlineStart? .isNoOp != false ) &&
49+ (_left? .isNoOp != false ) &&
50+ (_right? .isNoOp != false ) &&
51+ (_top? .isNoOp != false ) &&
5252 radiusBottomLeft == CssRadius .zero &&
5353 radiusBottomRight == CssRadius .zero &&
5454 radiusTopLeft == CssRadius .zero &&
@@ -189,27 +189,51 @@ class CssBorderSide {
189189 /// A border that is not rendered.
190190 static const none = CssBorderSide ();
191191
192- BorderSide ? _getValue (TextStyleHtml tsh) => identical (this , none)
193- ? null
194- : BorderSide (
195- color: color ?? tsh.style.color ?? const BorderSide ().color,
196- // TODO: add proper support for other border styles
197- style: style != null ? BorderStyle .solid : BorderStyle .none,
198- // TODO: look for official document regarding this default value
199- // WebKit & Blink seem to follow the same (hidden?) specs
200- width: width? .getValue (tsh) ?? 1.0 ,
201- );
192+ /// Returns `true` if either [style] or [width] is invalid.
193+ ///
194+ /// Border will use the default text color so [color] is not required.
195+ bool get isNoOp => style == null || width? .isPositive != true ;
196+
197+ BorderSide ? _getValue (TextStyleHtml tsh) {
198+ if (identical (this , none)) {
199+ return null ;
200+ }
202201
203- static CssBorderSide ? _copyWith (CssBorderSide ? base , CssBorderSide ? value) =>
204- base == null || value == none
205- ? value
206- : value == null
207- ? base
208- : CssBorderSide (
209- color: value.color ?? base .color,
210- style: value.style ?? base .style,
211- width: value.width ?? base .width,
212- );
202+ final scopedColor = color ?? tsh.style.color;
203+ if (scopedColor == null ) {
204+ return null ;
205+ }
206+
207+ final scopedWidth = width? .getValue (tsh);
208+ if (scopedWidth == null ) {
209+ return null ;
210+ }
211+
212+ return BorderSide (
213+ color: scopedColor,
214+ // TODO: add proper support for other border styles
215+ style: style != null ? BorderStyle .solid : BorderStyle .none,
216+ width: scopedWidth,
217+ );
218+ }
219+
220+ static CssBorderSide ? _copyWith (CssBorderSide ? base , CssBorderSide ? value) {
221+ final copied = base == null || value == none
222+ ? value
223+ : value == null
224+ ? base
225+ : CssBorderSide (
226+ color: value.color ?? base .color,
227+ style: value.style ?? base .style,
228+ width: value.width ?? base .width,
229+ );
230+
231+ if (copied? .isNoOp == true ) {
232+ return none;
233+ }
234+
235+ return copied;
236+ }
213237}
214238
215239/// A length measurement.
0 commit comments