Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2019-03-02 07:15:32 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6da22fc29153daae54462070d8132216c01eb850
6da22fc2
1 parent
e9ef1ee9
Add assert to verify that layout correctly set a box
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
0 deletions
pdf/lib/widgets/basic.dart
pdf/lib/widgets/document.dart
pdf/lib/widgets/flex.dart
pdf/lib/widgets/grid_view.dart
pdf/lib/widgets/multi_page.dart
pdf/lib/widgets/stack.dart
pdf/lib/widgets/table.dart
pdf/lib/widgets/widget.dart
pdf/lib/widgets/basic.dart
View file @
6da22fc
...
...
@@ -50,6 +50,7 @@ class LimitedBox extends SingleChildWidget {
if
(
child
!=
null
)
{
child
.
layout
(
context
,
_limitConstraints
(
constraints
),
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
size
=
constraints
.
constrain
(
child
.
box
.
size
);
}
else
{
size
=
_limitConstraints
(
constraints
).
constrain
(
PdfPoint
.
zero
);
...
...
@@ -73,6 +74,7 @@ class Padding extends SingleChildWidget {
if
(
child
!=
null
)
{
final
BoxConstraints
childConstraints
=
constraints
.
deflate
(
padding
);
child
.
layout
(
context
,
childConstraints
,
parentUsesSize:
parentUsesSize
);
assert
(
child
.
box
!=
null
);
box
=
constraints
.
constrainRect
(
width:
child
.
box
.
width
+
padding
.
horizontal
,
height:
child
.
box
.
height
+
padding
.
vertical
);
...
...
@@ -239,6 +241,7 @@ class Align extends SingleChildWidget {
if
(
child
!=
null
)
{
child
.
layout
(
context
,
constraints
.
loosen
(),
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
box
=
constraints
.
constrainRect
(
width:
shrinkWrapWidth
...
...
@@ -272,6 +275,7 @@ class ConstrainedBox extends SingleChildWidget {
if
(
child
!=
null
)
{
child
.
layout
(
context
,
this
.
constraints
.
enforce
(
constraints
),
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
box
=
child
.
box
;
}
else
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
...
...
@@ -308,6 +312,7 @@ class FittedBox extends SingleChildWidget {
PdfPoint
size
;
if
(
child
!=
null
)
{
child
.
layout
(
context
,
const
BoxConstraints
(),
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
size
=
constraints
.
constrainSizeAndAttemptToPreserveAspectRatio
(
child
.
box
.
size
);
}
else
{
...
...
@@ -397,6 +402,7 @@ class AspectRatio extends SingleChildWidget {
if
(
child
!=
null
)
child
.
layout
(
context
,
BoxConstraints
.
tightFor
(
width:
box
.
width
,
height:
box
.
height
));
assert
(
child
.
box
!=
null
);
}
}
...
...
@@ -420,6 +426,7 @@ class CustomPaint extends SingleChildWidget {
if
(
child
!=
null
)
{
child
.
layout
(
context
,
constraints
.
tighten
(
width:
size
.
x
,
height:
size
.
y
),
parentUsesSize:
parentUsesSize
);
assert
(
child
.
box
!=
null
);
box
=
child
.
box
;
}
else
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
constrain
(
size
));
...
...
pdf/lib/widgets/document.dart
View file @
6da22fc
...
...
@@ -152,6 +152,7 @@ class Page {
if
(
child
!=
null
)
{
final
EdgeInsets
_margin
=
margin
;
child
.
layout
(
context
,
constraints
,
parentUsesSize:
parentUsesSize
);
assert
(
child
.
box
!=
null
);
child
.
box
=
PdfRect
(
_margin
.
left
,
pageFormat
.
height
-
child
.
box
.
height
-
_margin
.
top
,
...
...
pdf/lib/widgets/flex.dart
View file @
6da22fc
...
...
@@ -260,6 +260,7 @@ class Flex extends MultiChildWidget {
}
}
child
.
layout
(
context
,
innerConstraints
,
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
allocatedSize
+=
_getMainSize
(
child
);
crossSize
=
math
.
max
(
crossSize
,
_getCrossSize
(
child
));
}
...
...
@@ -329,6 +330,7 @@ class Flex extends MultiChildWidget {
}
}
child
.
layout
(
context
,
innerConstraints
,
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
final
double
childSize
=
_getMainSize
(
child
);
assert
(
childSize
<=
maxChildExtent
);
allocatedSize
+=
childSize
;
...
...
pdf/lib/widgets/grid_view.dart
View file @
6da22fc
...
...
@@ -138,6 +138,7 @@ class GridView extends MultiChildWidget implements SpanningWidget {
math
.
min
(
children
.
length
,
_context
.
firstChild
+
crossAxisCount
*
_mainAxisCount
)))
{
child
.
layout
(
context
,
innerConstraints
);
assert
(
child
.
box
!=
null
);
switch
(
direction
)
{
case
Axis
.
vertical
:
...
...
pdf/lib/widgets/multi_page.dart
View file @
6da22fc
...
...
@@ -143,6 +143,7 @@ class MultiPage extends Page {
final
Widget
headerWidget
=
header
(
context
);
if
(
headerWidget
!=
null
)
{
headerWidget
.
layout
(
context
,
constraints
,
parentUsesSize:
false
);
assert
(
headerWidget
.
box
!=
null
);
_paintChild
(
context
,
headerWidget
,
_margin
.
left
,
offsetStart
-
headerWidget
.
box
.
height
,
pageFormat
.
height
);
offsetStart
-=
headerWidget
.
box
.
height
;
...
...
@@ -153,6 +154,7 @@ class MultiPage extends Page {
final
Widget
footerWidget
=
footer
(
context
);
if
(
footerWidget
!=
null
)
{
footerWidget
.
layout
(
context
,
constraints
,
parentUsesSize:
false
);
assert
(
footerWidget
.
box
!=
null
);
_paintChild
(
context
,
footerWidget
,
_margin
.
left
,
_margin
.
bottom
,
pageFormat
.
height
);
offsetEnd
+=
footerWidget
.
box
.
height
;
...
...
@@ -167,6 +169,7 @@ class MultiPage extends Page {
}
child
.
layout
(
context
,
constraints
,
parentUsesSize:
false
);
assert
(
child
.
box
!=
null
);
// What to do if the widget is too big for the page?
if
(
offsetStart
-
child
.
box
.
height
<
offsetEnd
)
{
...
...
@@ -191,6 +194,7 @@ class MultiPage extends Page {
child
.
layout
(
context
,
constraints
.
copyWith
(
maxHeight:
offsetStart
-
offsetEnd
),
parentUsesSize:
false
);
assert
(
child
.
box
!=
null
);
_paintChild
(
context
,
child
,
_margin
.
left
,
offsetStart
-
child
.
box
.
height
,
pageFormat
.
height
);
...
...
pdf/lib/widgets/stack.dart
View file @
6da22fc
...
...
@@ -100,6 +100,7 @@ class Stack extends MultiChildWidget {
hasNonPositionedChildren
=
true
;
child
.
layout
(
context
,
nonPositionedConstraints
,
parentUsesSize:
true
);
assert
(
child
.
box
!=
null
);
final
PdfRect
childSize
=
child
.
box
;
width
=
math
.
max
(
width
,
childSize
.
width
);
...
...
@@ -137,6 +138,7 @@ class Stack extends MultiChildWidget {
childConstraints
.
tighten
(
height:
positioned
.
height
);
positioned
.
layout
(
context
,
childConstraints
,
parentUsesSize:
true
);
assert
(
positioned
.
box
!=
null
);
double
x
;
if
(
positioned
.
left
!=
null
)
{
...
...
pdf/lib/widgets/table.dart
View file @
6da22fc
...
...
@@ -163,6 +163,7 @@ class Table extends Widget implements SpanningWidget {
int
n
=
0
;
for
(
Widget
child
in
row
.
children
)
{
child
.
layout
(
context
,
const
BoxConstraints
());
assert
(
child
.
box
!=
null
);
final
double
calculatedWidth
=
child
.
box
.
width
==
double
.
infinity
?
0.0
:
child
.
box
.
width
;
final
double
childFlex
=
child
is
Expanded
...
...
@@ -227,6 +228,7 @@ class Table extends Widget implements SpanningWidget {
final
BoxConstraints
childConstraints
=
BoxConstraints
.
tightFor
(
width:
_widths
[
n
]);
child
.
layout
(
context
,
childConstraints
);
assert
(
child
.
box
!=
null
);
child
.
box
=
PdfRect
(
x
,
totalHeight
,
child
.
box
.
width
,
child
.
box
.
height
);
x
+=
_widths
[
n
];
lineHeight
=
math
.
max
(
lineHeight
,
child
.
box
.
height
);
...
...
pdf/lib/widgets/widget.dart
View file @
6da22fc
...
...
@@ -104,6 +104,7 @@ abstract class StatelessWidget extends Widget {
if
(
_child
!=
null
)
{
_child
.
layout
(
context
,
constraints
,
parentUsesSize:
parentUsesSize
);
assert
(
_child
.
box
!=
null
);
box
=
_child
.
box
;
}
else
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
smallest
);
...
...
@@ -139,6 +140,7 @@ abstract class SingleChildWidget extends Widget {
{
bool
parentUsesSize
=
false
})
{
if
(
child
!=
null
)
{
child
.
layout
(
context
,
constraints
,
parentUsesSize:
parentUsesSize
);
assert
(
child
.
box
!=
null
);
box
=
child
.
box
;
}
else
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
smallest
);
...
...
Please
register
or
login
to post a comment