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-09-18 19:20:05 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d6bdb80b40b227be5297c56158cd7abba139e4a
6d6bdb80
1 parent
e16c789b
Improve Container tests
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
48 deletions
pdf/test/widget_container_test.dart
pdf/test/widget_container_test.dart
View file @
6d6bdb8
...
...
@@ -24,7 +24,7 @@ import 'package:pdf/widgets.dart';
Document
pdf
;
Uint32List
generateBitmap
(
int
w
,
int
h
)
{
PdfImage
generateBitmap
(
PdfDocument
pdf
,
int
w
,
int
h
)
{
final
Uint32List
bm
=
Uint32List
(
w
*
h
);
final
double
dw
=
w
.
toDouble
();
final
double
dh
=
h
.
toDouble
();
...
...
@@ -37,7 +37,12 @@ Uint32List generateBitmap(int w, int h) {
}
}
return
bm
;
return
PdfImage
(
pdf
,
image:
bm
.
buffer
.
asUint8List
(),
width:
w
,
height:
h
,
);
}
void
main
(
)
{
...
...
@@ -71,56 +76,43 @@ void main() {
});
test
(
'Container Widgets Image'
,
()
{
final
Uint32List
img
=
generateBitmap
(
100
,
100
);
final
PdfImage
image
=
PdfImage
(
pdf
.
document
,
image:
img
.
buffer
.
asUint8List
(),
width:
100
,
height:
100
);
final
PdfImage
image
=
generateBitmap
(
pdf
.
document
,
100
,
200
);
pdf
.
addPage
(
Page
(
build:
(
Context
context
)
=>
Container
(
alignment:
Alignment
.
center
,
margin:
const
EdgeInsets
.
all
(
30
),
padding:
const
EdgeInsets
.
all
(
20
),
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
image
,
fit:
BoxFit
.
cover
),
),
width:
200
,
height:
400
,
// child: Placeholder(),
),
));
});
test
(
'Container Widgets BoxShape Image'
,
()
{
final
Uint32List
img
=
generateBitmap
(
100
,
100
);
final
PdfImage
image
=
PdfImage
(
pdf
.
document
,
image:
img
.
buffer
.
asUint8List
(),
width:
100
,
height:
100
);
pdf
.
addPage
(
Page
(
build:
(
Context
context
)
=>
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Container
(
height:
200.0
,
width:
200.0
,
decoration:
BoxDecoration
(
shape:
BoxShape
.
circle
,
image:
DecorationImage
(
image:
image
,
fit:
BoxFit
.
cover
),
),
final
List
<
Widget
>
widgets
=
<
Widget
>[];
for
(
BoxShape
shape
in
BoxShape
.
values
)
{
for
(
BoxFit
fit
in
BoxFit
.
values
)
{
widgets
.
add
(
Container
(
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
shape:
shape
,
borderRadius:
10
,
image:
DecorationImage
(
image:
image
,
fit:
fit
),
),
Container
(
height:
200.0
,
width:
200.0
,
decoration:
BoxDecoration
(
shape:
BoxShape
.
rectangle
,
borderRadius:
40
,
image:
DecorationImage
(
image:
image
,
fit:
BoxFit
.
cover
),
width:
100
,
height:
100
,
child:
Container
(
width:
70
,
color:
PdfColors
.
yellow
,
child:
Text
(
'
$fit
\n
$shape
'
,
textAlign:
TextAlign
.
center
,
textScaleFactor:
0.6
,
),
),
],
),
),
));
),
);
}
}
pdf
.
addPage
(
MultiPage
(
build:
(
Context
context
)
=>
<
Widget
>[
Wrap
(
spacing:
10
,
runSpacing:
10
,
children:
widgets
,
)
]));
});
test
(
'Container Widgets BoxShape Border'
,
()
{
...
...
Please
register
or
login
to post a comment