Showing
2 changed files
with
14 additions
and
6 deletions
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | - Add LinearProgressIndicator | 7 | - Add LinearProgressIndicator |
8 | - Add PdfOutline.toString() | 8 | - Add PdfOutline.toString() |
9 | - Add equality operator to PdfPageFormat | 9 | - Add equality operator to PdfPageFormat |
10 | +- Improve TextStyle decoration merging | ||
10 | 11 | ||
11 | ## 3.3.0 | 12 | ## 3.3.0 |
12 | 13 |
@@ -43,11 +43,6 @@ class TextDecoration { | @@ -43,11 +43,6 @@ class TextDecoration { | ||
43 | 43 | ||
44 | final int _mask; | 44 | final int _mask; |
45 | 45 | ||
46 | - /// Whether this decoration will paint at least as much decoration as the given decoration. | ||
47 | - bool contains(TextDecoration other) { | ||
48 | - return (_mask | other._mask) == _mask; | ||
49 | - } | ||
50 | - | ||
51 | /// Do not draw a decoration | 46 | /// Do not draw a decoration |
52 | static const TextDecoration none = TextDecoration._(0x0); | 47 | static const TextDecoration none = TextDecoration._(0x0); |
53 | 48 | ||
@@ -60,6 +55,18 @@ class TextDecoration { | @@ -60,6 +55,18 @@ class TextDecoration { | ||
60 | /// Draw a line through each line of text | 55 | /// Draw a line through each line of text |
61 | static const TextDecoration lineThrough = TextDecoration._(0x4); | 56 | static const TextDecoration lineThrough = TextDecoration._(0x4); |
62 | 57 | ||
58 | + TextDecoration merge(TextDecoration? other) { | ||
59 | + if (other == null) { | ||
60 | + return this; | ||
61 | + } | ||
62 | + return TextDecoration._(_mask | other._mask); | ||
63 | + } | ||
64 | + | ||
65 | + /// Whether this decoration will paint at least as much decoration as the given decoration. | ||
66 | + bool contains(TextDecoration other) { | ||
67 | + return (_mask | other._mask) == _mask; | ||
68 | + } | ||
69 | + | ||
63 | @override | 70 | @override |
64 | bool operator ==(dynamic other) { | 71 | bool operator ==(dynamic other) { |
65 | if (other is! TextDecoration) { | 72 | if (other is! TextDecoration) { |
@@ -340,7 +347,7 @@ class TextStyle { | @@ -340,7 +347,7 @@ class TextStyle { | ||
340 | lineSpacing: other.lineSpacing, | 347 | lineSpacing: other.lineSpacing, |
341 | height: other.height, | 348 | height: other.height, |
342 | background: other.background, | 349 | background: other.background, |
343 | - decoration: other.decoration, | 350 | + decoration: decoration?.merge(other.decoration), |
344 | decorationColor: other.decorationColor, | 351 | decorationColor: other.decorationColor, |
345 | decorationStyle: other.decorationStyle, | 352 | decorationStyle: other.decorationStyle, |
346 | decorationThickness: other.decorationThickness, | 353 | decorationThickness: other.decorationThickness, |
-
Please register or login to post a comment