@@ -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 &&
@@ -193,27 +193,51 @@ class CssBorderSide {
193193 /// A border that is not rendered.
194194 static const none = CssBorderSide ();
195195
196- BorderSide ? _getValue (HtmlStyle style) => identical (this , none)
197- ? null
198- : BorderSide (
199- color: color ?? style.textStyle.color ?? const BorderSide ().color,
200- // TODO: add proper support for other border styles
201- style: this .style != null ? BorderStyle .solid : BorderStyle .none,
202- // TODO: look for official document regarding this default value
203- // WebKit & Blink seem to follow the same (hidden?) specs
204- width: width? .getValue (style) ?? 1.0 ,
205- );
196+ /// Returns `true` if either [style] or [width] is invalid.
197+ ///
198+ /// Border will use the default text color so [color] is not required.
199+ bool get isNoOp => style == null || width? .isPositive != true ;
200+
201+ BorderSide ? _getValue (HtmlStyle style) {
202+ if (identical (this , none)) {
203+ return null ;
204+ }
206205
207- static CssBorderSide ? _copyWith (CssBorderSide ? base , CssBorderSide ? value) =>
208- base == null || value == none
209- ? value
210- : value == null
211- ? base
212- : CssBorderSide (
213- color: value.color ?? base .color,
214- style: value.style ?? base .style,
215- width: value.width ?? base .width,
216- );
206+ final scopedColor = color ?? style.textStyle.color;
207+ if (scopedColor == null ) {
208+ return null ;
209+ }
210+
211+ final scopedWidth = width? .getValue (style);
212+ if (scopedWidth == null ) {
213+ return null ;
214+ }
215+
216+ return BorderSide (
217+ color: scopedColor,
218+ // TODO: add proper support for other border styles
219+ style: this .style != null ? BorderStyle .solid : BorderStyle .none,
220+ width: scopedWidth,
221+ );
222+ }
223+
224+ static CssBorderSide ? _copyWith (CssBorderSide ? base , CssBorderSide ? value) {
225+ final copied = base == null || value == none
226+ ? value
227+ : value == null
228+ ? base
229+ : CssBorderSide (
230+ color: value.color ?? base .color,
231+ style: value.style ?? base .style,
232+ width: value.width ?? base .width,
233+ );
234+
235+ if (copied? .isNoOp == true ) {
236+ return none;
237+ }
238+
239+ return copied;
240+ }
217241}
218242
219243/// A length measurement.
0 commit comments