David PHAM-VAN

Add better debugPaint on Align Widget

# Changelog
## 1.3.16
* Add better debugPaint on Align Widget
## 1.3.15
* Fix Image shape inside BoxDecoration
... ...
... ... @@ -38,6 +38,9 @@ class PdfRect {
double get right => x + width;
double get top => y + height;
double get horizondalCenter => x + width / 2;
double get verticalCenter => y + height / 2;
@deprecated
double get l => left;
@deprecated
... ...
... ... @@ -257,6 +257,82 @@ class Align extends SingleChildWidget {
}
@override
void debugPaint(Context context) {
context.canvas
..setStrokeColor(PdfColors.green)
..drawRect(box.x, box.y, box.width, box.height);
if (child == null) {
context.canvas.strokePath();
return;
}
if (child.box.bottom > box.bottom) {
final double headSize =
math.min((child.box.bottom - box.bottom) * 0.2, 10);
context.canvas
..moveTo(
box.left + child.box.horizondalCenter,
box.bottom,
)
..lineTo(box.left + child.box.horizondalCenter,
box.bottom + child.box.bottom)
..lineTo(box.left + child.box.horizondalCenter - headSize,
box.bottom + child.box.bottom - headSize)
..moveTo(box.left + child.box.horizondalCenter,
box.bottom + child.box.bottom)
..lineTo(box.left + child.box.horizondalCenter + headSize,
box.bottom + child.box.bottom - headSize);
}
if (box.bottom + child.box.top < box.top) {
final double headSize =
math.min((box.top - child.box.top - box.bottom) * 0.2, 10);
context.canvas
..moveTo(box.left + child.box.horizondalCenter, box.top)
..lineTo(
box.left + child.box.horizondalCenter, box.bottom + child.box.top)
..lineTo(box.left + child.box.horizondalCenter - headSize,
box.bottom + child.box.top + headSize)
..moveTo(
box.left + child.box.horizondalCenter, box.bottom + child.box.top)
..lineTo(box.left + child.box.horizondalCenter + headSize,
box.bottom + child.box.top + headSize);
}
if (child.box.left > box.left) {
final double headSize = math.min((child.box.left - box.left) * 0.2, 10);
context.canvas
..moveTo(box.left, box.bottom + child.box.verticalCenter)
..lineTo(
box.left + child.box.left, box.bottom + child.box.verticalCenter)
..lineTo(box.left + child.box.left - headSize,
box.bottom + child.box.verticalCenter - headSize)
..moveTo(
box.left + child.box.left, box.bottom + child.box.verticalCenter)
..lineTo(box.left + child.box.left - headSize,
box.bottom + child.box.verticalCenter + headSize);
}
if (box.left + child.box.right < box.right) {
final double headSize =
math.min((box.right - child.box.right - box.left) * 0.2, 10);
context.canvas
..moveTo(box.right, box.bottom + child.box.verticalCenter)
..lineTo(
box.left + child.box.right, box.bottom + child.box.verticalCenter)
..lineTo(box.left + child.box.right + headSize,
box.bottom + child.box.verticalCenter - headSize)
..moveTo(
box.left + child.box.right, box.bottom + child.box.verticalCenter)
..lineTo(box.left + child.box.right + headSize,
box.bottom + child.box.verticalCenter + headSize);
}
context.canvas.strokePath();
}
@override
void paint(Context context) {
super.paint(context);
paintChild(context);
... ...
... ... @@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository: https://github.com/DavBfr/dart_pdf
issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version: 1.3.15
version: 1.3.16
environment:
sdk: ">=2.1.0 <3.0.0"
... ...
... ... @@ -28,7 +28,7 @@ void main() {
pdf = Document();
});
test('Basic Widgets Align', () {
test('Basic Widgets Align 1', () {
pdf.addPage(Page(
build: (Context context) => Align(
alignment: Alignment.bottomRight,
... ... @@ -36,6 +36,14 @@ void main() {
)));
});
test('Basic Widgets Align 2', () {
pdf.addPage(Page(
build: (Context context) => Align(
alignment: const Alignment(0.8, 0.2),
child: SizedBox(width: 100, height: 100, child: PdfLogo()),
)));
});
test('Basic Widgets AspectRatio', () {
pdf.addPage(Page(
build: (Context context) => AspectRatio(
... ...