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
2020-12-18 18:14:53 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
75cd93f88a01fc320d5bcc68326cd75ba9c66fc0
75cd93f8
1 parent
fad280e8
Add Border and BorderSide objects
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
95 additions
and
70 deletions
demo/lib/report.dart
pdf/CHANGELOG.md
pdf/lib/widgets/chart/chart.dart
pdf/lib/widgets/decoration.dart
pdf/lib/widgets/forms.dart
pdf/test/widget_container_test.dart
pdf/test/widget_form_test.dart
pdf/test/widget_test.dart
demo/lib/report.dart
View file @
75cd93f
...
...
@@ -59,13 +59,9 @@ Future<Uint8List> generateReport(PdfPageFormat pageFormat) async {
),
overlay:
pw
.
ChartLegend
(
position:
const
pw
.
Alignment
(-.
7
,
1
),
decoration:
const
pw
.
BoxDecoration
(
decoration:
pw
.
BoxDecoration
(
color:
PdfColors
.
white
,
border:
pw
.
BoxBorder
(
bottom:
true
,
top:
true
,
left:
true
,
right:
true
,
border:
pw
.
Border
.
all
(
color:
PdfColors
.
black
,
width:
.
5
,
),
...
...
pdf/CHANGELOG.md
View file @
75cd93f
...
...
@@ -19,6 +19,7 @@
-
Remove dependency to the deprecated utf library
-
Fix RichText.maxLines with multiple TextSpan
-
Fix Exif parsing
-
Add Border and BorderSide objects
## 1.12.0
...
...
pdf/lib/widgets/chart/chart.dart
View file @
75cd93f
...
...
@@ -162,11 +162,7 @@ abstract class Dataset extends Widget {
return
Container
(
decoration:
BoxDecoration
(
color:
color
,
border:
const
BoxBorder
(
left:
true
,
top:
true
,
bottom:
true
,
right:
true
,
border:
Border
.
all
(
color:
PdfColors
.
black
,
width:
.
5
,
),
...
...
pdf/lib/widgets/decoration.dart
View file @
75cd93f
...
...
@@ -152,6 +152,74 @@ class BoxBorder {
}
}
/// A side of a border of a box.
class
BorderSide
{
/// Creates the side of a border.
const
BorderSide
({
this
.
color
=
PdfColors
.
black
,
this
.
width
=
1.0
,
this
.
style
=
BorderStyle
.
solid
,
});
/// The color of this side of the border.
final
PdfColor
color
;
/// The width of this side of the border.
final
double
width
;
/// The style of this side of the border.
final
BorderStyle
style
;
BorderSide
copyWith
({
PdfColor
color
,
double
width
,
BorderStyle
style
,
})
=>
BorderSide
(
color:
color
,
width:
width
,
style:
style
,
);
}
/// A border of a box, comprised of four sides: top, right, bottom, left.
class
Border
extends
BoxBorder
{
const
Border
.
_
(
bool
left
,
bool
top
,
bool
right
,
bool
bottom
,
PdfColor
color
,
double
width
,
BorderStyle
style
)
:
super
(
left:
left
,
top:
top
,
right:
right
,
bottom:
bottom
,
color:
color
,
width:
width
,
style:
style
,
);
/// A uniform border with all sides the same color and width.
factory
Border
.
all
({
PdfColor
color
=
PdfColors
.
black
,
double
width
=
1.0
,
BorderStyle
style
=
BorderStyle
.
solid
,
})
=>
Border
.
_
(
true
,
true
,
true
,
true
,
color
,
width
,
style
,
);
/// Creates a border whose sides are all the same.
factory
Border
.
fromBorderSide
(
BorderSide
side
)
=>
Border
.
all
(
color:
side
.
color
,
width:
side
.
width
,
style:
side
.
style
,
);
}
@immutable
class
DecorationImage
{
@Deprecated
(
'Use DecorationImage.provider()'
)
...
...
pdf/lib/widgets/forms.dart
View file @
75cd93f
...
...
@@ -42,12 +42,8 @@ class Checkbox extends SingleChildWidget {
height:
height
,
margin:
const
EdgeInsets
.
all
(
1
),
decoration:
decoration
??
const
BoxDecoration
(
border:
BoxBorder
(
left:
true
,
top:
true
,
bottom:
true
,
right:
true
,
BoxDecoration
(
border:
Border
.
all
(
color:
PdfColors
.
grey600
,
width:
2
,
))));
...
...
pdf/test/widget_container_test.dart
View file @
75cd93f
...
...
@@ -36,15 +36,11 @@ void main() {
alignment:
Alignment
.
center
,
margin:
const
EdgeInsets
.
all
(
30
),
padding:
const
EdgeInsets
.
all
(
20
),
decoration:
const
BoxDecoration
(
decoration:
BoxDecoration
(
color:
PdfColors
.
blue
,
borderRadiusEx:
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
border:
BoxBorder
(
borderRadiusEx:
const
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
border:
Border
.
all
(
color:
PdfColors
.
blue800
,
top:
true
,
left:
true
,
right:
true
,
bottom:
true
,
width:
2
,
)),
width:
200
,
...
...
@@ -103,30 +99,18 @@ void main() {
Container
(
height:
200.0
,
width:
200.0
,
decoration:
const
BoxDecoration
(
decoration:
BoxDecoration
(
shape:
BoxShape
.
circle
,
border:
BoxBorder
(
bottom:
true
,
top:
true
,
left:
true
,
right:
true
,
color:
PdfColors
.
blue
,
width:
3
),
border:
Border
.
all
(
color:
PdfColors
.
blue
,
width:
3
),
),
),
Container
(
height:
200.0
,
width:
200.0
,
decoration:
const
BoxDecoration
(
decoration:
BoxDecoration
(
shape:
BoxShape
.
rectangle
,
borderRadiusEx:
BorderRadius
.
all
(
Radius
.
circular
(
40
)),
border:
BoxBorder
(
bottom:
true
,
top:
true
,
left:
true
,
right:
true
,
color:
PdfColors
.
blue
,
width:
3
),
borderRadiusEx:
const
BorderRadius
.
all
(
Radius
.
circular
(
40
)),
border:
Border
.
all
(
color:
PdfColors
.
blue
,
width:
3
),
),
),
],
...
...
@@ -141,9 +125,9 @@ void main() {
alignment:
Alignment
.
center
,
margin:
const
EdgeInsets
.
all
(
30
),
padding:
const
EdgeInsets
.
all
(
20
),
decoration:
const
BoxDecoration
(
borderRadiusEx:
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
gradient:
LinearGradient
(
decoration:
BoxDecoration
(
borderRadiusEx:
const
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
gradient:
const
LinearGradient
(
colors:
<
PdfColor
>[
PdfColors
.
blue
,
PdfColors
.
red
,
...
...
@@ -154,12 +138,8 @@ void main() {
stops:
<
double
>[
0
,
.
8
,
1.0
],
tileMode:
TileMode
.
clamp
,
),
border:
Bo
xBorder
(
border:
Bo
rder
.
all
(
color:
PdfColors
.
blue800
,
top:
true
,
left:
true
,
right:
true
,
bottom:
true
,
width:
2
,
)),
width:
200
,
...
...
@@ -174,9 +154,9 @@ void main() {
alignment:
Alignment
.
center
,
margin:
const
EdgeInsets
.
all
(
30
),
padding:
const
EdgeInsets
.
all
(
20
),
decoration:
const
BoxDecoration
(
borderRadiusEx:
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
gradient:
RadialGradient
(
decoration:
BoxDecoration
(
borderRadiusEx:
const
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
gradient:
const
RadialGradient
(
colors:
<
PdfColor
>[
PdfColors
.
blue
,
PdfColors
.
red
,
...
...
@@ -187,12 +167,8 @@ void main() {
focal:
FractionalOffset
(.
7
,
.
45
),
focalRadius:
1
,
),
border:
Bo
xBorder
(
border:
Bo
rder
.
all
(
color:
PdfColors
.
blue800
,
top:
true
,
left:
true
,
right:
true
,
bottom:
true
,
width:
2
,
)),
width:
200
,
...
...
pdf/test/widget_form_test.dart
View file @
75cd93f
...
...
@@ -54,11 +54,7 @@ class Decorated extends StatelessWidget {
padding:
const
EdgeInsets
.
all
(
2
),
decoration:
BoxDecoration
(
color:
color
??
PdfColors
.
yellow100
,
border:
const
BoxBorder
(
left:
true
,
top:
true
,
right:
true
,
bottom:
true
,
border:
Border
.
all
(
color:
PdfColors
.
grey
,
width:
.
5
,
),
...
...
pdf/test/widget_test.dart
View file @
75cd93f
...
...
@@ -54,14 +54,10 @@ void main() {
Container
(
padding:
const
EdgeInsets
.
all
(
5
),
margin:
const
EdgeInsets
.
only
(
bottom:
10
),
decoration:
const
BoxDecoration
(
color:
PdfColors
.
amber
,
border:
BoxBorder
(
top:
true
,
bottom:
true
,
left:
true
,
right:
true
,
width:
2
)),
decoration:
BoxDecoration
(
color:
PdfColors
.
amber
,
border:
Border
.
all
(
width:
2
),
),
child:
Text
(
'Hello World'
,
textScaleFactor:
2
,
...
...
Please
register
or
login
to post a comment