Showing
6 changed files
with
64 additions
and
71 deletions
| @@ -123,7 +123,7 @@ abstract class PdfAnnotBase { | @@ -123,7 +123,7 @@ abstract class PdfAnnotBase { | ||
| 123 | /// Color | 123 | /// Color |
| 124 | final PdfColor? color; | 124 | final PdfColor? color; |
| 125 | 125 | ||
| 126 | - final Map<String, PdfDataType> _appearances = <String, PdfDataType>{}; | 126 | + final _appearances = <String, PdfDataType>{}; |
| 127 | 127 | ||
| 128 | PdfName? _as; | 128 | PdfName? _as; |
| 129 | 129 | ||
| @@ -171,19 +171,13 @@ abstract class PdfAnnotBase { | @@ -171,19 +171,13 @@ abstract class PdfAnnotBase { | ||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | if (matrix != null) { | 173 | if (matrix != null) { |
| 174 | - s.params['/Matrix'] = PdfArray.fromNum(<double>[ | ||
| 175 | - matrix[0], | ||
| 176 | - matrix[1], | ||
| 177 | - matrix[4], | ||
| 178 | - matrix[5], | ||
| 179 | - matrix[12], | ||
| 180 | - matrix[13] | ||
| 181 | - ]); | 174 | + s.params['/Matrix'] = PdfArray.fromNum( |
| 175 | + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]]); | ||
| 182 | } | 176 | } |
| 183 | 177 | ||
| 184 | final bbox = boundingBox ?? PdfRect.fromPoints(PdfPoint.zero, rect.size); | 178 | final bbox = boundingBox ?? PdfRect.fromPoints(PdfPoint.zero, rect.size); |
| 185 | s.params['/BBox'] = | 179 | s.params['/BBox'] = |
| 186 | - PdfArray.fromNum(<double?>[bbox.x, bbox.y, bbox.width, bbox.height]); | 180 | + PdfArray.fromNum([bbox.x, bbox.y, bbox.width, bbox.height]); |
| 187 | final g = PdfGraphics(s, s.buf); | 181 | final g = PdfGraphics(s, s.buf); |
| 188 | 182 | ||
| 189 | if (selected && name != null) { | 183 | if (selected && name != null) { |
| @@ -196,14 +190,14 @@ abstract class PdfAnnotBase { | @@ -196,14 +190,14 @@ abstract class PdfAnnotBase { | ||
| 196 | @mustCallSuper | 190 | @mustCallSuper |
| 197 | void build(PdfPage page, PdfObject object, PdfDict params) { | 191 | void build(PdfPage page, PdfObject object, PdfDict params) { |
| 198 | params['/Subtype'] = PdfName(subtype); | 192 | params['/Subtype'] = PdfName(subtype); |
| 199 | - params['/Rect'] = PdfArray.fromNum( | ||
| 200 | - <double?>[rect.left, rect.bottom, rect.right, rect.top]); | 193 | + params['/Rect'] = |
| 194 | + PdfArray.fromNum([rect.left, rect.bottom, rect.right, rect.top]); | ||
| 201 | 195 | ||
| 202 | params['/P'] = page.ref(); | 196 | params['/P'] = page.ref(); |
| 203 | 197 | ||
| 204 | // handle the border | 198 | // handle the border |
| 205 | if (border == null) { | 199 | if (border == null) { |
| 206 | - params['/Border'] = PdfArray.fromNum(const <int>[0, 0, 0]); | 200 | + params['/Border'] = PdfArray.fromNum(const [0, 0, 0]); |
| 207 | } else { | 201 | } else { |
| 208 | params['/BS'] = border!.ref(); | 202 | params['/BS'] = border!.ref(); |
| 209 | } | 203 | } |
| @@ -283,7 +277,7 @@ class PdfAnnotNamedLink extends PdfAnnotBase { | @@ -283,7 +277,7 @@ class PdfAnnotNamedLink extends PdfAnnotBase { | ||
| 283 | void build(PdfPage page, PdfObject object, PdfDict params) { | 277 | void build(PdfPage page, PdfObject object, PdfDict params) { |
| 284 | super.build(page, object, params); | 278 | super.build(page, object, params); |
| 285 | params['/A'] = PdfDict( | 279 | params['/A'] = PdfDict( |
| 286 | - <String, PdfDataType>{ | 280 | + { |
| 287 | '/S': const PdfName('/GoTo'), | 281 | '/S': const PdfName('/GoTo'), |
| 288 | '/D': PdfSecString.fromString(object, dest), | 282 | '/D': PdfSecString.fromString(object, dest), |
| 289 | }, | 283 | }, |
| @@ -315,7 +309,7 @@ class PdfAnnotUrlLink extends PdfAnnotBase { | @@ -315,7 +309,7 @@ class PdfAnnotUrlLink extends PdfAnnotBase { | ||
| 315 | void build(PdfPage page, PdfObject object, PdfDict params) { | 309 | void build(PdfPage page, PdfObject object, PdfDict params) { |
| 316 | super.build(page, object, params); | 310 | super.build(page, object, params); |
| 317 | params['/A'] = PdfDict( | 311 | params['/A'] = PdfDict( |
| 318 | - <String, PdfDataType>{ | 312 | + { |
| 319 | '/S': const PdfName('/URI'), | 313 | '/S': const PdfName('/URI'), |
| 320 | '/URI': PdfSecString.fromString(object, url), | 314 | '/URI': PdfSecString.fromString(object, url), |
| 321 | }, | 315 | }, |
| @@ -115,7 +115,7 @@ class PdfNum extends PdfDataType { | @@ -115,7 +115,7 @@ class PdfNum extends PdfDataType { | ||
| 115 | class PdfNumList extends PdfDataType { | 115 | class PdfNumList extends PdfDataType { |
| 116 | PdfNumList(this.values); | 116 | PdfNumList(this.values); |
| 117 | 117 | ||
| 118 | - final List<num?> values; | 118 | + final List<num> values; |
| 119 | 119 | ||
| 120 | @override | 120 | @override |
| 121 | void output(PdfStream s) { | 121 | void output(PdfStream s) { |
| @@ -123,7 +123,7 @@ class PdfNumList extends PdfDataType { | @@ -123,7 +123,7 @@ class PdfNumList extends PdfDataType { | ||
| 123 | if (n > 0) { | 123 | if (n > 0) { |
| 124 | s.putByte(0x20); | 124 | s.putByte(0x20); |
| 125 | } | 125 | } |
| 126 | - PdfNum(values[n]!).output(s); | 126 | + PdfNum(values[n]).output(s); |
| 127 | } | 127 | } |
| 128 | } | 128 | } |
| 129 | 129 | ||
| @@ -448,13 +448,13 @@ class PdfArray<T extends PdfDataType> extends PdfDataType { | @@ -448,13 +448,13 @@ class PdfArray<T extends PdfDataType> extends PdfDataType { | ||
| 448 | } | 448 | } |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | - static PdfArray<PdfIndirect> fromObjects(List<PdfObject?> objects) { | 451 | + static PdfArray<PdfIndirect> fromObjects(List<PdfObject> objects) { |
| 452 | return PdfArray( | 452 | return PdfArray( |
| 453 | - objects.map<PdfIndirect>((PdfObject? e) => e!.ref()).toList()); | 453 | + objects.map<PdfIndirect>((PdfObject e) => e.ref()).toList()); |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | - static PdfArray<PdfNum> fromNum(List<num?> list) { | ||
| 457 | - return PdfArray(list.map<PdfNum>((num? e) => PdfNum(e!)).toList()); | 456 | + static PdfArray<PdfNum> fromNum(List<num> list) { |
| 457 | + return PdfArray(list.map<PdfNum>((num e) => PdfNum(e)).toList()); | ||
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | final List<T> values = <T>[]; | 460 | final List<T> values = <T>[]; |
| @@ -111,13 +111,13 @@ class PdfGraphics { | @@ -111,13 +111,13 @@ class PdfGraphics { | ||
| 111 | late _PdfGraphicsContext _context; | 111 | late _PdfGraphicsContext _context; |
| 112 | final Queue<_PdfGraphicsContext> _contextQueue = Queue<_PdfGraphicsContext>(); | 112 | final Queue<_PdfGraphicsContext> _contextQueue = Queue<_PdfGraphicsContext>(); |
| 113 | 113 | ||
| 114 | - final PdfGraphicStream? _page; | 114 | + final PdfGraphicStream _page; |
| 115 | 115 | ||
| 116 | /// Buffer where to write the graphic operations | 116 | /// Buffer where to write the graphic operations |
| 117 | final PdfStream buf; | 117 | final PdfStream buf; |
| 118 | 118 | ||
| 119 | /// Default font if none selected | 119 | /// Default font if none selected |
| 120 | - PdfFont? get defaultFont => _page!.getDefaultFont(); | 120 | + PdfFont? get defaultFont => _page.getDefaultFont(); |
| 121 | 121 | ||
| 122 | /// Draw a surface on the previously defined shape | 122 | /// Draw a surface on the previously defined shape |
| 123 | /// set evenOdd to false to use the nonzero winding number rule to determine the region to fill and to true to use the even-odd rule to determine the region to fill | 123 | /// set evenOdd to false to use the nonzero winding number rule to determine the region to fill and to true to use the even-odd rule to determine the region to fill |
| @@ -150,7 +150,7 @@ class PdfGraphics { | @@ -150,7 +150,7 @@ class PdfGraphics { | ||
| 150 | /// Apply a shader | 150 | /// Apply a shader |
| 151 | void applyShader(PdfShading shader) { | 151 | void applyShader(PdfShading shader) { |
| 152 | // The shader needs to be registered in the page resources | 152 | // The shader needs to be registered in the page resources |
| 153 | - _page!.addShader(shader); | 153 | + _page.addShader(shader); |
| 154 | buf.putString('${shader.name} sh\n'); | 154 | buf.putString('${shader.name} sh\n'); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| @@ -179,7 +179,7 @@ class PdfGraphics { | @@ -179,7 +179,7 @@ class PdfGraphics { | ||
| 179 | h ??= img.height.toDouble() * w / img.width.toDouble(); | 179 | h ??= img.height.toDouble() * w / img.width.toDouble(); |
| 180 | 180 | ||
| 181 | // The image needs to be registered in the page resources | 181 | // The image needs to be registered in the page resources |
| 182 | - _page!.addXObject(img); | 182 | + _page.addXObject(img); |
| 183 | 183 | ||
| 184 | // q w 0 0 h x y cm % the coordinate matrix | 184 | // q w 0 0 h x y cm % the coordinate matrix |
| 185 | buf.putString('q '); | 185 | buf.putString('q '); |
| @@ -214,7 +214,7 @@ class PdfGraphics { | @@ -214,7 +214,7 @@ class PdfGraphics { | ||
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | /// Draws a line between two coordinates. | 216 | /// Draws a line between two coordinates. |
| 217 | - void drawLine(double? x1, double? y1, double? x2, double? y2) { | 217 | + void drawLine(double x1, double y1, double x2, double y2) { |
| 218 | moveTo(x1, y1); | 218 | moveTo(x1, y1); |
| 219 | lineTo(x2, y2); | 219 | lineTo(x2, y2); |
| 220 | } | 220 | } |
| @@ -230,12 +230,12 @@ class PdfGraphics { | @@ -230,12 +230,12 @@ class PdfGraphics { | ||
| 230 | 230 | ||
| 231 | /// Draws a Rectangle | 231 | /// Draws a Rectangle |
| 232 | void drawRect( | 232 | void drawRect( |
| 233 | - double? x, | ||
| 234 | - double? y, | ||
| 235 | - double? w, | ||
| 236 | - double? h, | 233 | + double x, |
| 234 | + double y, | ||
| 235 | + double w, | ||
| 236 | + double h, | ||
| 237 | ) { | 237 | ) { |
| 238 | - PdfNumList(<double?>[x, y, w, h]).output(buf); | 238 | + PdfNumList([x, y, w, h]).output(buf); |
| 239 | buf.putString(' re\n'); | 239 | buf.putString(' re\n'); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| @@ -297,18 +297,18 @@ class PdfGraphics { | @@ -297,18 +297,18 @@ class PdfGraphics { | ||
| 297 | PdfFont font, | 297 | PdfFont font, |
| 298 | double size, | 298 | double size, |
| 299 | String s, | 299 | String s, |
| 300 | - double? x, | 300 | + double x, |
| 301 | double y, { | 301 | double y, { |
| 302 | - double? charSpace = 0, | 302 | + double charSpace = 0, |
| 303 | double wordSpace = 0, | 303 | double wordSpace = 0, |
| 304 | double scale = 1, | 304 | double scale = 1, |
| 305 | - PdfTextRenderingMode? mode = PdfTextRenderingMode.fill, | 305 | + PdfTextRenderingMode mode = PdfTextRenderingMode.fill, |
| 306 | double rise = 0, | 306 | double rise = 0, |
| 307 | }) { | 307 | }) { |
| 308 | - _page!.addFont(font); | 308 | + _page.addFont(font); |
| 309 | 309 | ||
| 310 | buf.putString('BT '); | 310 | buf.putString('BT '); |
| 311 | - PdfNumList(<double?>[x, y]).output(buf); | 311 | + PdfNumList([x, y]).output(buf); |
| 312 | buf.putString(' Td '); | 312 | buf.putString(' Td '); |
| 313 | setFont(font, size, | 313 | setFont(font, size, |
| 314 | charSpace: charSpace, | 314 | charSpace: charSpace, |
| @@ -358,20 +358,20 @@ class PdfGraphics { | @@ -358,20 +358,20 @@ class PdfGraphics { | ||
| 358 | /// Sets the fill pattern for drawing | 358 | /// Sets the fill pattern for drawing |
| 359 | void setFillPattern(PdfPattern pattern) { | 359 | void setFillPattern(PdfPattern pattern) { |
| 360 | // The shader needs to be registered in the page resources | 360 | // The shader needs to be registered in the page resources |
| 361 | - _page!.addPattern(pattern); | 361 | + _page.addPattern(pattern); |
| 362 | buf.putString('/Pattern cs${pattern.name} scn\n'); | 362 | buf.putString('/Pattern cs${pattern.name} scn\n'); |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | /// Sets the stroke pattern for drawing | 365 | /// Sets the stroke pattern for drawing |
| 366 | void setStrokePattern(PdfPattern pattern) { | 366 | void setStrokePattern(PdfPattern pattern) { |
| 367 | // The shader needs to be registered in the page resources | 367 | // The shader needs to be registered in the page resources |
| 368 | - _page!.addPattern(pattern); | 368 | + _page.addPattern(pattern); |
| 369 | buf.putString('/Pattern CS${pattern.name} SCN\n'); | 369 | buf.putString('/Pattern CS${pattern.name} SCN\n'); |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | /// Set the graphic state for drawing | 372 | /// Set the graphic state for drawing |
| 373 | void setGraphicState(PdfGraphicState state) { | 373 | void setGraphicState(PdfGraphicState state) { |
| 374 | - final name = _page!.stateName(state); | 374 | + final name = _page.stateName(state); |
| 375 | buf.putString('$name gs\n'); | 375 | buf.putString('$name gs\n'); |
| 376 | } | 376 | } |
| 377 | 377 | ||
| @@ -389,14 +389,14 @@ class PdfGraphics { | @@ -389,14 +389,14 @@ class PdfGraphics { | ||
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | /// This adds a line segment to the current path | 391 | /// This adds a line segment to the current path |
| 392 | - void lineTo(double? x, double? y) { | ||
| 393 | - PdfNumList(<double?>[x, y]).output(buf); | 392 | + void lineTo(double x, double y) { |
| 393 | + PdfNumList([x, y]).output(buf); | ||
| 394 | buf.putString(' l\n'); | 394 | buf.putString(' l\n'); |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | /// This moves the current drawing point. | 397 | /// This moves the current drawing point. |
| 398 | - void moveTo(double? x, double? y) { | ||
| 399 | - PdfNumList(<double?>[x, y]).output(buf); | 398 | + void moveTo(double x, double y) { |
| 399 | + PdfNumList([x, y]).output(buf); | ||
| 400 | buf.putString(' m\n'); | 400 | buf.putString(' m\n'); |
| 401 | } | 401 | } |
| 402 | 402 | ||
| @@ -404,8 +404,8 @@ class PdfGraphics { | @@ -404,8 +404,8 @@ class PdfGraphics { | ||
| 404 | /// using (x1,y1) as the control point at the beginning of the curve | 404 | /// using (x1,y1) as the control point at the beginning of the curve |
| 405 | /// and (x2,y2) as the control point at the end of the curve. | 405 | /// and (x2,y2) as the control point at the end of the curve. |
| 406 | void curveTo( | 406 | void curveTo( |
| 407 | - double? x1, double? y1, double? x2, double? y2, double? x3, double? y3) { | ||
| 408 | - PdfNumList(<double?>[x1, y1, x2, y2, x3, y3]).output(buf); | 407 | + double x1, double y1, double x2, double y2, double x3, double y3) { |
| 408 | + PdfNumList([x1, y1, x2, y2, x3, y3]).output(buf); | ||
| 409 | buf.putString(' c\n'); | 409 | buf.putString(' c\n'); |
| 410 | } | 410 | } |
| 411 | 411 | ||
| @@ -524,7 +524,7 @@ class PdfGraphics { | @@ -524,7 +524,7 @@ class PdfGraphics { | ||
| 524 | /// the constraints imposed by the other parameters. large and sweep flags | 524 | /// the constraints imposed by the other parameters. large and sweep flags |
| 525 | /// contribute to the automatic calculations and help determine how the arc is drawn. | 525 | /// contribute to the automatic calculations and help determine how the arc is drawn. |
| 526 | void bezierArc( | 526 | void bezierArc( |
| 527 | - double? x1, double? y1, double rx, double ry, double? x2, double? y2, | 527 | + double x1, double y1, double rx, double ry, double x2, double y2, |
| 528 | {bool large = false, bool sweep = false, double phi = 0.0}) { | 528 | {bool large = false, bool sweep = false, double phi = 0.0}) { |
| 529 | if (x1 == x2 && y1 == y2) { | 529 | if (x1 == x2 && y1 == y2) { |
| 530 | // From https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes: | 530 | // From https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes: |
| @@ -542,12 +542,12 @@ class PdfGraphics { | @@ -542,12 +542,12 @@ class PdfGraphics { | ||
| 542 | // Our box bézier arcs can't handle rotations directly | 542 | // Our box bézier arcs can't handle rotations directly |
| 543 | // move to a well known point, eliminate phi and transform the other point | 543 | // move to a well known point, eliminate phi and transform the other point |
| 544 | final mat = Matrix4.identity(); | 544 | final mat = Matrix4.identity(); |
| 545 | - mat.translate(-x1!, -y1!); | 545 | + mat.translate(-x1, -y1); |
| 546 | mat.rotateZ(-phi); | 546 | mat.rotateZ(-phi); |
| 547 | - final tr = mat.transform3(Vector3(x2!, y2!, 0)); | 547 | + final tr = mat.transform3(Vector3(x2, y2, 0)); |
| 548 | _endToCenterParameters(0, 0, tr[0], tr[1], large, sweep, rx, ry); | 548 | _endToCenterParameters(0, 0, tr[0], tr[1], large, sweep, rx, ry); |
| 549 | } else { | 549 | } else { |
| 550 | - _endToCenterParameters(x1!, y1!, x2!, y2!, large, sweep, rx, ry); | 550 | + _endToCenterParameters(x1, y1, x2, y2, large, sweep, rx, ry); |
| 551 | } | 551 | } |
| 552 | } | 552 | } |
| 553 | 553 |
| @@ -64,7 +64,7 @@ class PdfShading extends PdfObject { | @@ -64,7 +64,7 @@ class PdfShading extends PdfObject { | ||
| 64 | 64 | ||
| 65 | params['/ShadingType'] = PdfNum(shadingType.index + 2); | 65 | params['/ShadingType'] = PdfNum(shadingType.index + 2); |
| 66 | if (boundingBox != null) { | 66 | if (boundingBox != null) { |
| 67 | - params['/BBox'] = PdfArray.fromNum(<double?>[ | 67 | + params['/BBox'] = PdfArray.fromNum([ |
| 68 | boundingBox!.left, | 68 | boundingBox!.left, |
| 69 | boundingBox!.bottom, | 69 | boundingBox!.bottom, |
| 70 | boundingBox!.right, | 70 | boundingBox!.right, |
| @@ -75,13 +75,12 @@ class PdfShading extends PdfObject { | @@ -75,13 +75,12 @@ class PdfShading extends PdfObject { | ||
| 75 | params['/ColorSpace'] = const PdfName('/DeviceRGB'); | 75 | params['/ColorSpace'] = const PdfName('/DeviceRGB'); |
| 76 | 76 | ||
| 77 | if (shadingType == PdfShadingType.axial) { | 77 | if (shadingType == PdfShadingType.axial) { |
| 78 | - params['/Coords'] = | ||
| 79 | - PdfArray.fromNum(<double?>[start.x, start.y, end.x, end.y]); | 78 | + params['/Coords'] = PdfArray.fromNum([start.x, start.y, end.x, end.y]); |
| 80 | } else if (shadingType == PdfShadingType.radial) { | 79 | } else if (shadingType == PdfShadingType.radial) { |
| 81 | assert(radius0 != null); | 80 | assert(radius0 != null); |
| 82 | assert(radius1 != null); | 81 | assert(radius1 != null); |
| 83 | params['/Coords'] = PdfArray.fromNum( | 82 | params['/Coords'] = PdfArray.fromNum( |
| 84 | - <double?>[start.x, start.y, radius0, end.x, end.y, radius1]); | 83 | + [start.x, start.y, radius0!, end.x, end.y, radius1!]); |
| 85 | } | 84 | } |
| 86 | // params['/Domain'] = PdfArray.fromNum(<num>[0, 1]); | 85 | // params['/Domain'] = PdfArray.fromNum(<num>[0, 1]); |
| 87 | if (extendStart || extendEnd) { | 86 | if (extendStart || extendEnd) { |
| @@ -30,19 +30,19 @@ class PdfSoftMask { | @@ -30,19 +30,19 @@ class PdfSoftMask { | ||
| 30 | bool knockout = false, | 30 | bool knockout = false, |
| 31 | bool invert = false}) { | 31 | bool invert = false}) { |
| 32 | _mask = PdfGraphicXObject(document); | 32 | _mask = PdfGraphicXObject(document); |
| 33 | - _mask!.params['/BBox'] = PdfArray.fromNum([ | 33 | + _mask.params['/BBox'] = PdfArray.fromNum([ |
| 34 | boundingBox.x, | 34 | boundingBox.x, |
| 35 | boundingBox.y, | 35 | boundingBox.y, |
| 36 | boundingBox.width, | 36 | boundingBox.width, |
| 37 | boundingBox.height, | 37 | boundingBox.height, |
| 38 | ]); | 38 | ]); |
| 39 | if (isolated) { | 39 | if (isolated) { |
| 40 | - _mask!.params['/I'] = const PdfBool(true); | 40 | + _mask.params['/I'] = const PdfBool(true); |
| 41 | } | 41 | } |
| 42 | if (knockout) { | 42 | if (knockout) { |
| 43 | - _mask!.params['/K'] = const PdfBool(true); | 43 | + _mask.params['/K'] = const PdfBool(true); |
| 44 | } | 44 | } |
| 45 | - _graphics = PdfGraphics(_mask, _mask!.buf); | 45 | + _graphics = PdfGraphics(_mask, _mask.buf); |
| 46 | 46 | ||
| 47 | if (invert) { | 47 | if (invert) { |
| 48 | _tr = PdfFunction( | 48 | _tr = PdfFunction( |
| @@ -54,7 +54,7 @@ class PdfSoftMask { | @@ -54,7 +54,7 @@ class PdfSoftMask { | ||
| 54 | 54 | ||
| 55 | final PdfDocument document; | 55 | final PdfDocument document; |
| 56 | 56 | ||
| 57 | - PdfGraphicXObject? _mask; | 57 | + late PdfGraphicXObject _mask; |
| 58 | 58 | ||
| 59 | PdfGraphics? _graphics; | 59 | PdfGraphics? _graphics; |
| 60 | 60 | ||
| @@ -65,7 +65,7 @@ class PdfSoftMask { | @@ -65,7 +65,7 @@ class PdfSoftMask { | ||
| 65 | PdfDict output() { | 65 | PdfDict output() { |
| 66 | final params = PdfDict({ | 66 | final params = PdfDict({ |
| 67 | '/S': const PdfName('/Luminosity'), | 67 | '/S': const PdfName('/Luminosity'), |
| 68 | - '/G': _mask!.ref(), | 68 | + '/G': _mask.ref(), |
| 69 | }); | 69 | }); |
| 70 | 70 | ||
| 71 | if (_tr != null) { | 71 | if (_tr != null) { |
| @@ -55,7 +55,7 @@ abstract class _Span { | @@ -55,7 +55,7 @@ abstract class _Span { | ||
| 55 | 55 | ||
| 56 | void paint( | 56 | void paint( |
| 57 | Context context, | 57 | Context context, |
| 58 | - TextStyle? style, | 58 | + TextStyle style, |
| 59 | double textScaleFactor, | 59 | double textScaleFactor, |
| 60 | PdfPoint point, | 60 | PdfPoint point, |
| 61 | ); | 61 | ); |
| @@ -261,18 +261,18 @@ class _Word extends _Span { | @@ -261,18 +261,18 @@ class _Word extends _Span { | ||
| 261 | @override | 261 | @override |
| 262 | void paint( | 262 | void paint( |
| 263 | Context context, | 263 | Context context, |
| 264 | - TextStyle? style, | 264 | + TextStyle style, |
| 265 | double textScaleFactor, | 265 | double textScaleFactor, |
| 266 | PdfPoint point, | 266 | PdfPoint point, |
| 267 | ) { | 267 | ) { |
| 268 | context.canvas.drawString( | 268 | context.canvas.drawString( |
| 269 | - style!.font!.getFont(context)!, | 269 | + style.font!.getFont(context)!, |
| 270 | style.fontSize! * textScaleFactor, | 270 | style.fontSize! * textScaleFactor, |
| 271 | text, | 271 | text, |
| 272 | point.x + offset.x, | 272 | point.x + offset.x, |
| 273 | point.y + offset.y, | 273 | point.y + offset.y, |
| 274 | - mode: style.renderingMode, | ||
| 275 | - charSpace: style.letterSpacing, | 274 | + mode: style.renderingMode ?? PdfTextRenderingMode.fill, |
| 275 | + charSpace: style.letterSpacing ?? 0, | ||
| 276 | ); | 276 | ); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| @@ -312,10 +312,10 @@ class _WidgetSpan extends _Span { | @@ -312,10 +312,10 @@ class _WidgetSpan extends _Span { | ||
| 312 | double get top => 0; | 312 | double get top => 0; |
| 313 | 313 | ||
| 314 | @override | 314 | @override |
| 315 | - double? get width => widget.box!.width; | 315 | + double get width => widget.box!.width; |
| 316 | 316 | ||
| 317 | @override | 317 | @override |
| 318 | - double? get height => widget.box!.height; | 318 | + double get height => widget.box!.height; |
| 319 | 319 | ||
| 320 | @override | 320 | @override |
| 321 | PdfPoint get offset => widget.box!.offset; | 321 | PdfPoint get offset => widget.box!.offset; |
| @@ -755,7 +755,7 @@ class RichText extends Widget { | @@ -755,7 +755,7 @@ class RichText extends Widget { | ||
| 755 | style, | 755 | style, |
| 756 | ); | 756 | ); |
| 757 | 757 | ||
| 758 | - if (offsetX + ws.width! > constraintWidth && spanCount > 0) { | 758 | + if (offsetX + ws.width > constraintWidth && spanCount > 0) { |
| 759 | overflow = true; | 759 | overflow = true; |
| 760 | lines.add(_Line( | 760 | lines.add(_Line( |
| 761 | this, | 761 | this, |
| @@ -786,8 +786,8 @@ class RichText extends Widget { | @@ -786,8 +786,8 @@ class RichText extends Widget { | ||
| 786 | final baseline = span.baseline! * textScaleFactor; | 786 | final baseline = span.baseline! * textScaleFactor; |
| 787 | top = math.min(top ?? baseline, baseline); | 787 | top = math.min(top ?? baseline, baseline); |
| 788 | bottom = math.max( | 788 | bottom = math.max( |
| 789 | - bottom ?? ws.height! + baseline, | ||
| 790 | - ws.height! + baseline, | 789 | + bottom ?? ws.height + baseline, |
| 790 | + ws.height + baseline, | ||
| 791 | ); | 791 | ); |
| 792 | 792 | ||
| 793 | ws.offset = PdfPoint(offsetX, -offsetY + baseline); | 793 | ws.offset = PdfPoint(offsetX, -offsetY + baseline); |
| @@ -804,7 +804,7 @@ class RichText extends Widget { | @@ -804,7 +804,7 @@ class RichText extends Widget { | ||
| 804 | ), | 804 | ), |
| 805 | ); | 805 | ); |
| 806 | 806 | ||
| 807 | - offsetX += ws.left + ws.width!; | 807 | + offsetX += ws.left + ws.width; |
| 808 | } | 808 | } |
| 809 | 809 | ||
| 810 | return true; | 810 | return true; |
| @@ -897,7 +897,7 @@ class RichText extends Widget { | @@ -897,7 +897,7 @@ class RichText extends Widget { | ||
| 897 | 897 | ||
| 898 | span.paint( | 898 | span.paint( |
| 899 | context, | 899 | context, |
| 900 | - currentStyle, | 900 | + currentStyle!, |
| 901 | textScaleFactor, | 901 | textScaleFactor, |
| 902 | PdfPoint(box!.left, box!.top), | 902 | PdfPoint(box!.left, box!.top), |
| 903 | ); | 903 | ); |
-
Please register or login to post a comment