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-05-11 14:13:41 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4bc119d491eed26504f3ac9d409441f97dcbce20
4bc119d4
1 parent
b5886a45
Fix lint warnings
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
22 deletions
pdf/lib/src/annotation.dart
pdf/lib/src/output.dart
pdf/lib/widgets/basic.dart
pdf/lib/widgets/container.dart
pdf/lib/widgets/flex.dart
pdf/lib/widgets/geometry.dart
pdf/lib/widgets/stack.dart
pdf/lib/src/annotation.dart
View file @
4bc119d
...
...
@@ -133,9 +133,9 @@ class PdfAnnot extends PdfObject {
}
else
{
final
List
<
PdfStream
>
dests
=
<
PdfStream
>[];
dests
.
add
(
dest
.
ref
());
if
(
destRect
==
null
)
if
(
destRect
==
null
)
{
dests
.
add
(
PdfStream
.
string
(
'/Fit'
));
else
{
}
else
{
dests
.
add
(
PdfStream
.
string
(
'/FitR '
));
dests
.
add
(
PdfStream
()
..
putNumList
(<
double
>[
...
...
pdf/lib/src/output.dart
View file @
4bc119d
...
...
@@ -108,8 +108,9 @@ class PdfOutput {
os
.
putString
(
'/Root '
);
os
.
putStream
(
rootID
.
ref
());
os
.
putString
(
'
\n
'
);
}
else
}
else
{
throw
Exception
(
'Root object is not present in document'
);
}
// the /Info reference (OPTIONAL)
if
(
infoID
!=
null
)
{
...
...
pdf/lib/widgets/basic.dart
View file @
4bc119d
...
...
@@ -410,9 +410,10 @@ class AspectRatio extends SingleChildWidget {
void
layout
(
Context
context
,
BoxConstraints
constraints
,
{
bool
parentUsesSize
=
false
})
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
_applyAspectRatio
(
constraints
));
if
(
child
!=
null
)
if
(
child
!=
null
)
{
child
.
layout
(
context
,
BoxConstraints
.
tightFor
(
width:
box
.
width
,
height:
box
.
height
));
}
assert
(
child
.
box
!=
null
);
}
...
...
pdf/lib/widgets/container.dart
View file @
4bc119d
...
...
@@ -77,9 +77,10 @@ class BoxBorder {
context
.
canvas
.
lineTo
(
box
.
x
,
box
.
top
);
}
else
if
(
right
&&
top
)
{
context
.
canvas
.
closePath
();
}
else
}
else
{
context
.
canvas
.
lineTo
(
box
.
x
,
box
.
top
);
}
}
context
.
canvas
.
strokePath
();
}
...
...
@@ -151,12 +152,12 @@ class BoxDecoration {
if
(
color
!=
null
)
{
switch
(
shape
)
{
case
BoxShape
.
rectangle
:
if
(
borderRadius
==
null
)
if
(
borderRadius
==
null
)
{
context
.
canvas
.
drawRect
(
box
.
x
,
box
.
y
,
box
.
width
,
box
.
height
);
else
}
else
{
context
.
canvas
.
drawRRect
(
box
.
x
,
box
.
y
,
box
.
width
,
box
.
height
,
borderRadius
,
borderRadius
);
}
break
;
case
BoxShape
.
circle
:
context
.
canvas
.
drawEllipse
(
box
.
x
+
box
.
width
/
2.0
,
...
...
@@ -259,15 +260,17 @@ class Container extends StatelessWidget {
child:
ConstrainedBox
(
constraints:
const
BoxConstraints
.
expand
()));
}
if
(
alignment
!=
null
)
if
(
alignment
!=
null
)
{
current
=
Align
(
alignment:
alignment
,
child:
current
);
}
if
(
padding
!=
null
)
{
current
=
Padding
(
padding:
padding
,
child:
current
);
}
if
(
decoration
!=
null
)
if
(
decoration
!=
null
)
{
current
=
DecoratedBox
(
decoration:
decoration
,
child:
current
);
}
if
(
foregroundDecoration
!=
null
)
{
current
=
DecoratedBox
(
...
...
@@ -276,15 +279,17 @@ class Container extends StatelessWidget {
child:
current
);
}
if
(
constraints
!=
null
)
if
(
constraints
!=
null
)
{
current
=
ConstrainedBox
(
constraints:
constraints
,
child:
current
);
}
if
(
margin
!=
null
)
{
current
=
Padding
(
padding:
margin
,
child:
current
);
}
if
(
transform
!=
null
)
if
(
transform
!=
null
)
{
current
=
Transform
(
transform:
transform
,
child:
current
);
}
return
current
;
}
...
...
pdf/lib/widgets/flex.dart
View file @
4bc119d
...
...
@@ -144,10 +144,11 @@ class Flex extends MultiChildWidget {
// Size remaining (flexible) items, find the maximum cross size.
for
(
Widget
child
in
children
)
{
final
int
flex
=
child
is
Expanded
?
child
.
flex
:
0
;
if
(
flex
>
0
)
if
(
flex
>
0
)
{
maxCrossSize
=
math
.
max
(
maxCrossSize
,
childSize
(
child
,
spacePerFlex
*
flex
));
}
}
return
maxCrossSize
;
}
...
...
pdf/lib/widgets/geometry.dart
View file @
4bc119d
...
...
@@ -359,8 +359,9 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) {
if
(
inputSize
.
y
<=
0.0
||
inputSize
.
x
<=
0.0
||
outputSize
.
y
<=
0.0
||
outputSize
.
x
<=
0.0
)
outputSize
.
x
<=
0.0
)
{
return
const
FittedSizes
(
PdfPoint
.
zero
,
PdfPoint
.
zero
);
}
PdfPoint
sourceSize
,
destinationSize
;
switch
(
fit
)
{
...
...
@@ -370,12 +371,13 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) {
break
;
case
BoxFit
.
contain
:
sourceSize
=
inputSize
;
if
(
outputSize
.
x
/
outputSize
.
y
>
sourceSize
.
x
/
sourceSize
.
y
)
if
(
outputSize
.
x
/
outputSize
.
y
>
sourceSize
.
x
/
sourceSize
.
y
)
{
destinationSize
=
PdfPoint
(
sourceSize
.
x
*
outputSize
.
y
/
sourceSize
.
y
,
outputSize
.
y
);
else
}
else
{
destinationSize
=
PdfPoint
(
outputSize
.
x
,
sourceSize
.
y
*
outputSize
.
x
/
sourceSize
.
x
);
}
break
;
case
BoxFit
.
cover
:
if
(
outputSize
.
x
/
outputSize
.
y
>
inputSize
.
x
/
inputSize
.
y
)
{
...
...
@@ -408,10 +410,12 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) {
sourceSize
=
inputSize
;
destinationSize
=
inputSize
;
final
double
aspectRatio
=
inputSize
.
x
/
inputSize
.
y
;
if
(
destinationSize
.
y
>
outputSize
.
y
)
if
(
destinationSize
.
y
>
outputSize
.
y
)
{
destinationSize
=
PdfPoint
(
outputSize
.
y
*
aspectRatio
,
outputSize
.
y
);
if
(
destinationSize
.
x
>
outputSize
.
x
)
}
if
(
destinationSize
.
x
>
outputSize
.
x
)
{
destinationSize
=
PdfPoint
(
outputSize
.
x
,
outputSize
.
x
/
aspectRatio
);
}
break
;
}
return
FittedSizes
(
sourceSize
,
destinationSize
);
...
...
pdf/lib/widgets/stack.dart
View file @
4bc119d
...
...
@@ -130,18 +130,20 @@ class Stack extends MultiChildWidget {
final
Positioned
positioned
=
child
;
BoxConstraints
childConstraints
=
const
BoxConstraints
();
if
(
positioned
.
left
!=
null
&&
positioned
.
right
!=
null
)
if
(
positioned
.
left
!=
null
&&
positioned
.
right
!=
null
)
{
childConstraints
=
childConstraints
.
tighten
(
width:
box
.
width
-
positioned
.
right
-
positioned
.
left
);
else
if
(
positioned
.
width
!=
null
)
}
else
if
(
positioned
.
width
!=
null
)
{
childConstraints
=
childConstraints
.
tighten
(
width:
positioned
.
width
);
}
if
(
positioned
.
top
!=
null
&&
positioned
.
bottom
!=
null
)
if
(
positioned
.
top
!=
null
&&
positioned
.
bottom
!=
null
)
{
childConstraints
=
childConstraints
.
tighten
(
height:
box
.
height
-
positioned
.
bottom
-
positioned
.
top
);
else
if
(
positioned
.
height
!=
null
)
}
else
if
(
positioned
.
height
!=
null
)
{
childConstraints
=
childConstraints
.
tighten
(
height:
positioned
.
height
);
}
positioned
.
layout
(
context
,
childConstraints
,
parentUsesSize:
true
);
assert
(
positioned
.
box
!=
null
);
...
...
Please
register
or
login
to post a comment