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
2021-12-29 09:11:09 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
75feddd218b6cb88c580af282c44870c7977d065
75feddd2
1 parent
98baf60e
Optimize for loops
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
98 additions
and
98 deletions
pdf/lib/src/pdf/data_types.dart
pdf/lib/src/pdf/font/arabic.dart
pdf/lib/src/pdf/font/font_metrics.dart
pdf/lib/src/pdf/font/ttf_parser.dart
pdf/lib/src/pdf/font/ttf_writer.dart
pdf/lib/src/pdf/obj/catalog.dart
pdf/lib/src/pdf/obj/names.dart
pdf/lib/src/pdf/obj/outline.dart
pdf/lib/src/pdf/obj/ttffont.dart
pdf/lib/src/pdf/xref.dart
pdf/lib/src/widgets/barcode.dart
pdf/lib/src/widgets/chart/grid_cartesian.dart
pdf/lib/src/widgets/chart/grid_radial.dart
pdf/lib/src/widgets/chart/pie_chart.dart
pdf/lib/src/widgets/document.dart
pdf/lib/src/widgets/flex.dart
pdf/lib/src/widgets/grid_view.dart
pdf/lib/src/widgets/multi_page.dart
pdf/lib/src/widgets/partitions.dart
pdf/lib/src/widgets/stack.dart
pdf/lib/src/widgets/table.dart
pdf/lib/src/widgets/text.dart
pdf/lib/src/widgets/text_style.dart
pdf/lib/src/widgets/wrap.dart
pdf/test/arabic_test.dart
pdf/test/metrics_test.dart
pdf/test/widget_container_test.dart
pdf/test/widget_table_test.dart
pdf/test/widget_text_test.dart
pdf/test/widget_wrap_test.dart
pdf/lib/src/pdf/data_types.dart
View file @
75feddd
...
...
@@ -204,7 +204,7 @@ class PdfString extends PdfDataType {
encoding
.
add
(
unit
&
UNICODE_BYTE_ZERO_MASK
);
}
for
(
var
unit
in
str
.
codeUnits
)
{
for
(
final
unit
in
str
.
codeUnits
)
{
if
((
unit
>=
0
&&
unit
<
UNICODE_UTF16_RESERVED_LO
)
||
(
unit
>
UNICODE_UTF16_RESERVED_HI
&&
unit
<=
UNICODE_PLANE_ONE_MAX
))
{
add
(
unit
);
...
...
@@ -225,7 +225,7 @@ class PdfString extends PdfDataType {
/// Escape special characters
/// \ddd Character code ddd (octal)
void
_putTextBytes
(
PdfStream
s
,
List
<
int
>
b
)
{
for
(
var
c
in
b
)
{
for
(
final
c
in
b
)
{
switch
(
c
)
{
case
0x0a
:
// \n Line feed (LF)
s
.
putByte
(
0x5c
);
...
...
@@ -274,7 +274,7 @@ class PdfString extends PdfDataType {
switch
(
format
)
{
case
PdfStringFormat
.
binary
:
s
.
putByte
(
0x3c
);
for
(
var
byte
in
value
)
{
for
(
final
byte
in
value
)
{
s
.
putByte
(
_codeUnitForDigit
((
byte
&
0xF0
)
>>
4
));
s
.
putByte
(
_codeUnitForDigit
(
byte
&
0x0F
));
}
...
...
pdf/lib/src/pdf/font/arabic.dart
View file @
75feddd
...
...
@@ -326,7 +326,7 @@ Iterable<String> _parse(String text) sync* {
final
notArabicWords
=
<
List
<
int
>>[];
var
first
=
true
;
for
(
var
word
in
words
)
{
for
(
final
word
in
words
)
{
final
newWord
=
<
int
>[];
var
isNewWordArabic
=
false
;
...
...
@@ -375,7 +375,7 @@ Iterable<String> _parse(String text) sync* {
if
(
isNewWordArabic
)
{
isNewWordArabic
=
false
;
for
(
var
notArabicNewWord
in
notArabicWords
)
{
for
(
final
notArabicNewWord
in
notArabicWords
)
{
yield
'
${String.fromCharCodes(notArabicNewWord)}
'
;
}
notArabicWords
.
clear
();
...
...
pdf/lib/src/pdf/font/font_metrics.dart
View file @
75feddd
...
...
@@ -57,7 +57,7 @@ class PdfFontMetrics {
double
?
firstBearing
;
late
double
spacing
;
for
(
var
metric
in
metrics
)
{
for
(
final
metric
in
metrics
)
{
firstBearing
??=
metric
.
leftBearing
;
left
??=
metric
.
left
;
spacing
=
metric
.
advanceWidth
>
0
?
letterSpacing
:
0.0
;
...
...
pdf/lib/src/pdf/font/ttf_parser.dart
View file @
75feddd
...
...
@@ -303,15 +303,15 @@ class TtfParser {
/// https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
void
_parseGlyphs
()
{
final
baseOffset
=
tableOffsets
[
glyf_table
];
final
baseOffset
=
tableOffsets
[
glyf_table
]
!
;
final
hmtxOffset
=
tableOffsets
[
hmtx_table
]!;
final
unitsPerEm
=
this
.
unitsPerEm
;
final
numOfLongHorMetrics
=
this
.
numOfLongHorMetrics
;
final
defaultadvanceWidth
=
bytes
.
getUint16
(
hmtxOffset
+
(
numOfLongHorMetrics
-
1
)
*
4
);
var
glyphIndex
=
0
;
for
(
var
offset
in
glyphOffsets
)
{
final
xMin
=
bytes
.
getInt16
(
baseOffset
!
+
offset
+
2
);
// 2
for
(
final
offset
in
glyphOffsets
)
{
final
xMin
=
bytes
.
getInt16
(
baseOffset
+
offset
+
2
);
// 2
final
yMin
=
bytes
.
getInt16
(
baseOffset
+
offset
+
4
);
// 4
final
xMax
=
bytes
.
getInt16
(
baseOffset
+
offset
+
6
);
// 6
final
yMax
=
bytes
.
getInt16
(
baseOffset
+
offset
+
8
);
// 8
...
...
pdf/lib/src/pdf/font/ttf_writer.dart
View file @
75feddd
...
...
@@ -78,14 +78,14 @@ class TtfWriter {
final
glyph
=
ttf
.
readGlyph
(
ttf
.
charToGlyphIndexMap
[
chars
[
index
]]
??
0
).
copy
();
for
(
var
g
in
glyph
.
compounds
)
{
for
(
final
g
in
glyph
.
compounds
)
{
compounds
[
g
]
=
-
1
;
}
glyphsInfo
.
add
(
glyph
);
}
// Add compound glyphs
for
(
var
compound
in
compounds
.
keys
)
{
for
(
final
compound
in
compounds
.
keys
)
{
final
index
=
glyphsInfo
.
firstWhere
(
(
TtfGlyphInfo
glyph
)
=>
glyph
.
index
==
compound
,
orElse:
()
{
...
...
@@ -106,14 +106,14 @@ class TtfWriter {
glyphsInfo
.
add
(
glyph
);
// update compound indices
for
(
var
glyph
in
glyphsInfo
)
{
for
(
final
glyph
in
glyphsInfo
)
{
if
(
glyph
.
compounds
.
isNotEmpty
)
{
_updateCompoundGlyph
(
glyph
,
compounds
);
}
}
var
glyphsTableLength
=
0
;
for
(
var
glyph
in
glyphsInfo
)
{
for
(
final
glyph
in
glyphsInfo
)
{
glyphsTableLength
=
_wordAlign
(
glyphsTableLength
+
glyph
.
data
.
lengthInBytes
);
}
...
...
@@ -136,7 +136,7 @@ class TtfWriter {
{
final
loca
=
tables
[
TtfParser
.
loca_table
]!.
buffer
.
asByteData
();
var
index
=
0
;
for
(
var
glyph
in
glyphsInfo
)
{
for
(
final
glyph
in
glyphsInfo
)
{
if
(
ttf
.
indexToLocFormat
==
0
)
{
loca
.
setUint16
(
index
,
offset
~/
2
);
index
+=
2
;
...
...
@@ -195,7 +195,7 @@ class TtfWriter {
final
defaultadvanceWidth
=
ttf
.
bytes
.
getUint16
(
hmtxOffset
+
(
numOfLongHorMetrics
-
1
)
*
4
);
var
index
=
0
;
for
(
var
glyph
in
glyphsInfo
)
{
for
(
final
glyph
in
glyphsInfo
)
{
final
advanceWidth
=
glyph
.
index
<
numOfLongHorMetrics
?
ttf
.
bytes
.
getUint16
(
hmtxOffset
+
glyph
.
index
*
4
)
:
defaultadvanceWidth
;
...
...
pdf/lib/src/pdf/obj/catalog.dart
View file @
75feddd
...
...
@@ -104,8 +104,8 @@ class PdfCatalog extends PdfObjectDict {
}
final
widgets
=
<
PdfAnnot
>[];
for
(
var
page
in
pdfDocument
.
pdfPageList
.
pages
)
{
for
(
var
annot
in
page
.
annotations
)
{
for
(
final
page
in
pdfDocument
.
pdfPageList
.
pages
)
{
for
(
final
annot
in
page
.
annotations
)
{
if
(
annot
.
annot
.
subtype
==
'/Widget'
)
{
widgets
.
add
(
annot
);
}
...
...
pdf/lib/src/pdf/obj/names.dart
View file @
75feddd
...
...
@@ -55,7 +55,7 @@ class PdfNames extends PdfObjectDict {
final
keys
=
_dests
.
keys
.
toList
()..
sort
();
for
(
var
name
in
keys
)
{
for
(
final
name
in
keys
)
{
dests
.
add
(
PdfSecString
.
fromString
(
this
,
name
));
dests
.
add
(
_dests
[
name
]!);
}
...
...
pdf/lib/src/pdf/obj/outline.dart
View file @
75feddd
...
...
@@ -189,7 +189,7 @@ class PdfOutline extends PdfObjectDict {
var
c
=
outlines
.
length
;
// initially the number of kids
// now call each one for their descendants
for
(
var
o
in
outlines
)
{
for
(
final
o
in
outlines
)
{
c
+=
o
.
descendants
();
}
...
...
pdf/lib/src/pdf/obj/ttffont.dart
View file @
75feddd
...
...
@@ -163,7 +163,7 @@ class PdfTtfFont extends PdfFont {
final
runes
=
text
.
runes
;
stream
.
putByte
(
0x3c
);
for
(
var
rune
in
runes
)
{
for
(
final
rune
in
runes
)
{
var
char
=
unicodeCMap
.
cmap
.
indexOf
(
rune
);
if
(
char
==
-
1
)
{
char
=
unicodeCMap
.
cmap
.
length
;
...
...
pdf/lib/src/pdf/xref.dart
View file @
75feddd
...
...
@@ -100,7 +100,7 @@ class PdfXrefTable extends PdfDataType {
void
_writeblock
(
PdfStream
s
,
int
firstid
,
List
<
PdfXref
>
block
)
{
s
.
putString
(
'
$firstid
${block.length}
\n
'
);
for
(
var
x
in
block
)
{
for
(
final
x
in
block
)
{
s
.
putString
(
x
.
ref
());
s
.
putByte
(
0x0a
);
}
...
...
@@ -125,7 +125,7 @@ class PdfXrefTable extends PdfDataType {
type:
PdfCrossRefEntryType
.
free
,
));
for
(
var
x
in
offsets
)
{
for
(
final
x
in
offsets
)
{
// check to see if block is in range
if
(
x
.
id
!=
(
lastid
+
1
))
{
// no, so write this block, and reset
...
...
@@ -165,7 +165,7 @@ class PdfXrefTable extends PdfDataType {
// We need block 0 to exist
blocks
.
add
(
firstid
);
for
(
var
x
in
offsets
)
{
for
(
final
x
in
offsets
)
{
// check to see if block is in range
if
(
x
.
id
!=
(
lastid
+
1
))
{
// no, so store this block, and reset
...
...
@@ -195,7 +195,7 @@ class PdfXrefTable extends PdfDataType {
// Write offset zero, all zeros
ofs
+=
wl
;
for
(
var
x
in
offsets
)
{
for
(
final
x
in
offsets
)
{
ofs
=
x
.
cref
(
o
,
ofs
,
w
);
}
...
...
pdf/lib/src/widgets/barcode.dart
View file @
75feddd
...
...
@@ -64,7 +64,7 @@ class _BarcodeWidget extends Widget {
final
textList
=
<
BarcodeText
>[];
for
(
var
element
in
barcode
!.
makeBytes
(
for
(
final
element
in
barcode
!.
makeBytes
(
data
,
width:
box
!.
width
,
height:
box
!.
height
,
...
...
@@ -93,7 +93,7 @@ class _BarcodeWidget extends Widget {
if
(
drawText
!)
{
final
font
=
textStyle
!.
font
!.
getFont
(
context
);
for
(
var
text
in
textList
)
{
for
(
final
text
in
textList
)
{
final
metrics
=
font
!.
stringMetrics
(
text
.
text
);
final
top
=
box
!.
top
-
...
...
@@ -136,7 +136,7 @@ class _BarcodeWidget extends Widget {
super
.
debugPaint
(
context
);
if
(
drawText
!)
{
for
(
var
element
in
barcode
!.
makeBytes
(
for
(
final
element
in
barcode
!.
makeBytes
(
data
,
width:
box
!.
width
,
height:
box
!.
height
,
...
...
pdf/lib/src/widgets/chart/grid_cartesian.dart
View file @
75feddd
...
...
@@ -105,13 +105,13 @@ class CartesianGrid extends ChartGrid {
final
datasets
=
Chart
.
of
(
context
).
datasets
;
clip
(
context
,
box
!.
size
);
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
dataSet
.
paintBackground
(
context
);
}
context
.
canvas
.
restoreContext
();
paintBackground
(
context
);
clip
(
context
,
box
!.
size
);
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
dataSet
.
paint
(
context
);
}
context
.
canvas
.
restoreContext
();
...
...
pdf/lib/src/widgets/chart/grid_radial.dart
View file @
75feddd
...
...
@@ -69,13 +69,13 @@ class RadialGrid extends ChartGrid {
final
datasets
=
Chart
.
of
(
context
).
datasets
;
clip
(
context
,
box
!.
size
);
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
dataSet
.
paintBackground
(
context
);
}
context
.
canvas
.
restoreContext
();
paintBackground
(
context
);
clip
(
context
,
box
!.
size
);
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
dataSet
.
paint
(
context
);
}
context
.
canvas
.
restoreContext
();
...
...
pdf/lib/src/widgets/chart/pie_chart.dart
View file @
75feddd
...
...
@@ -88,19 +88,19 @@ class PieGrid extends ChartGrid {
Matrix4
.
translationValues
(
box
!.
width
/
2
,
box
!.
height
/
2
,
0
),
);
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
if
(
dataSet
is
PieDataSet
)
{
dataSet
.
paintBackground
(
context
);
}
}
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
if
(
dataSet
is
PieDataSet
)
{
dataSet
.
paint
(
context
);
}
}
for
(
var
dataSet
in
datasets
)
{
for
(
final
dataSet
in
datasets
)
{
if
(
dataSet
is
PieDataSet
)
{
dataSet
.
paintLegend
(
context
);
}
...
...
pdf/lib/src/widgets/document.dart
View file @
75feddd
...
...
@@ -121,7 +121,7 @@ class Document {
Future
<
Uint8List
>
save
()
async
{
if
(!
_paint
)
{
for
(
var
page
in
_pages
)
{
for
(
final
page
in
_pages
)
{
page
.
postProcess
(
this
);
}
_paint
=
true
;
...
...
pdf/lib/src/widgets/flex.dart
View file @
75feddd
...
...
@@ -118,7 +118,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
var
inflexibleSpace
=
0.0
;
var
maxFlexFractionSoFar
=
0.0
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
totalFlex
+=
flex
;
if
(
flex
>
0
)
{
...
...
@@ -140,7 +140,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
var
totalFlex
=
0
;
var
inflexibleSpace
=
0.0
;
var
maxCrossSize
=
0.0
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
totalFlex
+=
flex
;
double
?
mainSize
;
...
...
@@ -167,7 +167,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
math
.
max
(
0.0
,
(
availableMainSpace
!
-
inflexibleSpace
)
/
totalFlex
);
// Size remaining (flexible) items, find the maximum cross size.
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
if
(
flex
>
0
)
{
maxCrossSize
=
...
...
@@ -241,7 +241,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
var
allocatedSize
=
0.0
;
// Sum of the sizes of the non-flexible children.
var
index
=
_context
.
firstChild
;
for
(
var
child
in
children
.
sublist
(
_context
.
firstChild
))
{
for
(
final
child
in
children
.
sublist
(
_context
.
firstChild
))
{
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
final
fit
=
child
is
Flexible
?
child
.
fit
:
FlexFit
.
loose
;
if
(
flex
>
0
)
{
...
...
@@ -305,7 +305,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
final
spacePerFlex
=
canFlex
&&
totalFlex
>
0
?
(
freeSpace
/
totalFlex
)
:
double
.
nan
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
final
fit
=
child
is
Flexible
?
child
.
fit
:
FlexFit
.
loose
;
if
(
flex
>
0
)
{
...
...
pdf/lib/src/widgets/grid_view.dart
View file @
75feddd
...
...
@@ -162,7 +162,7 @@ class GridView extends MultiChildWidget with SpanningWidget {
var
c
=
0
;
_context
.
lastChild
=
_context
.
firstChild
;
for
(
var
child
in
children
.
sublist
(
for
(
final
child
in
children
.
sublist
(
_context
.
firstChild
,
math
.
min
(
children
.
length
,
_context
.
firstChild
+
crossAxisCount
*
_mainAxisCount
!)))
{
...
...
pdf/lib/src/widgets/multi_page.dart
View file @
75feddd
...
...
@@ -368,7 +368,7 @@ class MultiPage extends Page {
final
pageWidthMargin
=
_mustRotate
?
_margin
.
vertical
:
_margin
.
horizontal
;
final
availableWidth
=
pageWidth
-
pageWidthMargin
;
for
(
var
page
in
_pages
)
{
for
(
final
page
in
_pages
)
{
var
offsetStart
=
pageHeight
-
(
_mustRotate
?
pageHeightMargin
-
_margin
.
bottom
:
_margin
.
top
);
var
offsetEnd
=
...
...
@@ -386,7 +386,7 @@ class MultiPage extends Page {
var
totalFlex
=
0
;
var
allocatedSize
=
0.0
;
Widget
?
lastFlexChild
;
for
(
var
widget
in
page
.
widgets
)
{
for
(
final
widget
in
page
.
widgets
)
{
final
child
=
widget
.
child
;
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
if
(
flex
>
0
)
{
...
...
@@ -467,7 +467,7 @@ class MultiPage extends Page {
}
}
for
(
var
widget
in
page
.
widgets
)
{
for
(
final
widget
in
page
.
widgets
)
{
final
child
=
widget
.
child
;
final
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
...
...
@@ -505,7 +505,7 @@ class MultiPage extends Page {
}
var
pos
=
offsetStart
-
leadingSpace
;
for
(
var
widget
in
page
.
widgets
)
{
for
(
final
widget
in
page
.
widgets
)
{
pos
-=
widget
.
child
.
box
!.
height
;
late
double
x
;
switch
(
crossAxisAlignment
)
{
...
...
pdf/lib/src/widgets/partitions.dart
View file @
75feddd
...
...
@@ -135,7 +135,7 @@ class Partitions extends Widget with SpanningWidget {
// Calculate fixed width columns
var
index
=
0
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
if
(
child
.
flex
>
0
)
{
assert
(()
{
if
(!
canFlex
)
{
...
...
@@ -160,7 +160,7 @@ class Partitions extends Widget with SpanningWidget {
final
spacePerFlex
=
freeSpace
/
totalFlex
;
index
=
0
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
if
(
child
.
flex
>
0
)
{
final
childExtent
=
spacePerFlex
*
child
.
flex
;
allocatedSize
+=
childExtent
;
...
...
@@ -173,7 +173,7 @@ class Partitions extends Widget with SpanningWidget {
// Layout the columns and compute the total height
var
totalHeight
=
0.0
;
index
=
0
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
if
(
widths
[
index
]!
>
0
)
{
final
innerConstraints
=
BoxConstraints
(
minWidth:
widths
[
index
]!,
...
...
@@ -190,7 +190,7 @@ class Partitions extends Widget with SpanningWidget {
// Update Y positions
index
=
0
;
allocatedSize
=
0.0
;
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
if
(
widths
[
index
]!
>
0
)
{
final
offsetY
=
totalHeight
-
child
.
box
!.
height
;
child
.
box
=
PdfRect
.
fromPoints
(
...
...
@@ -213,7 +213,7 @@ class Partitions extends Widget with SpanningWidget {
context
.
canvas
..
saveContext
()
..
setTransform
(
mat
);
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
child
.
paint
(
context
);
}
context
.
canvas
.
restoreContext
();
...
...
pdf/lib/src/widgets/stack.dart
View file @
75feddd
...
...
@@ -147,7 +147,7 @@ class Stack extends MultiChildWidget {
break
;
}
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
if
(
child
is
!
Positioned
)
{
hasNonPositionedChildren
=
true
;
...
...
@@ -168,7 +168,7 @@ class Stack extends MultiChildWidget {
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
biggest
);
}
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
if
(
child
is
!
Positioned
)
{
child
.
box
=
PdfRect
.
fromPoints
(
alignment
.
inscribe
(
child
.
box
!.
size
,
box
!).
offset
,
child
.
box
!.
size
);
...
...
@@ -232,7 +232,7 @@ class Stack extends MultiChildWidget {
..
drawRect
(
0
,
0
,
box
!.
width
,
box
!.
height
)
..
clipPath
();
}
for
(
var
child
in
children
)
{
for
(
final
child
in
children
)
{
child
.
paint
(
context
);
}
context
.
canvas
.
restoreContext
();
...
...
pdf/lib/src/widgets/table.dart
View file @
75feddd
...
...
@@ -108,7 +108,7 @@ class TableBorder extends Border {
if
(
verticalInside
.
style
.
paint
)
{
verticalInside
.
style
.
setStyle
(
context
);
var
offset
=
box
.
x
;
for
(
var
width
in
widths
!.
sublist
(
0
,
widths
.
length
-
1
))
{
for
(
final
width
in
widths
!.
sublist
(
0
,
widths
.
length
-
1
))
{
offset
+=
width
!;
context
.
canvas
.
moveTo
(
offset
,
box
.
y
);
context
.
canvas
.
lineTo
(
offset
,
box
.
top
);
...
...
@@ -123,7 +123,7 @@ class TableBorder extends Border {
if
(
horizontalInside
.
style
.
paint
)
{
horizontalInside
.
style
.
setStyle
(
context
);
var
offset
=
box
.
top
;
for
(
var
height
in
heights
!.
sublist
(
0
,
heights
.
length
-
1
))
{
for
(
final
height
in
heights
!.
sublist
(
0
,
heights
.
length
-
1
))
{
offset
-=
height
;
context
.
canvas
.
moveTo
(
box
.
x
,
offset
);
context
.
canvas
.
lineTo
(
box
.
right
,
offset
);
...
...
@@ -437,9 +437,9 @@ class Table extends Widget with SpanningWidget {
_heights
.
clear
();
var
index
=
0
;
for
(
var
row
in
children
)
{
for
(
final
row
in
children
)
{
var
n
=
0
;
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
final
columnWidth
=
columnWidths
!=
null
&&
columnWidths
![
n
]
!=
null
?
columnWidths
![
n
]!
:
defaultColumnWidth
;
...
...
@@ -495,7 +495,7 @@ class Table extends Widget with SpanningWidget {
// Compute final widths
var
totalHeight
=
0.0
;
index
=
0
;
for
(
var
row
in
children
)
{
for
(
final
row
in
children
)
{
if
(
index
++
<
_context
.
firstLine
&&
!
row
.
repeat
)
{
continue
;
}
...
...
@@ -504,7 +504,7 @@ class Table extends Widget with SpanningWidget {
var
x
=
0.0
;
var
lineHeight
=
0.0
;
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
final
childConstraints
=
BoxConstraints
.
tightFor
(
width:
_widths
[
n
]);
child
.
layout
(
context
,
childConstraints
);
assert
(
child
.
box
!=
null
);
...
...
@@ -521,7 +521,7 @@ class Table extends Widget with SpanningWidget {
// Compute the layout again to give the full height to all cells
n
=
0
;
x
=
0
;
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
final
childConstraints
=
BoxConstraints
.
tightFor
(
width:
_widths
[
n
],
height:
lineHeight
);
child
.
layout
(
context
,
childConstraints
);
...
...
@@ -545,14 +545,14 @@ class Table extends Widget with SpanningWidget {
// Compute final y position
index
=
0
;
var
heightIndex
=
0
;
for
(
var
row
in
children
)
{
for
(
final
row
in
children
)
{
if
(
index
++
<
_context
.
firstLine
&&
!
row
.
repeat
)
{
continue
;
}
final
align
=
row
.
verticalAlignment
??
defaultVerticalAlignment
;
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
double
?
childY
;
switch
(
align
)
{
...
...
@@ -602,7 +602,7 @@ class Table extends Widget with SpanningWidget {
..
setTransform
(
mat
);
var
index
=
0
;
for
(
var
row
in
children
)
{
for
(
final
row
in
children
)
{
if
(
index
++
<
_context
.
firstLine
&&
!
row
.
repeat
)
{
continue
;
}
...
...
@@ -610,7 +610,7 @@ class Table extends Widget with SpanningWidget {
if
(
row
.
decoration
!=
null
)
{
var
y
=
double
.
infinity
;
var
h
=
0.0
;
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
y
=
math
.
min
(
y
,
child
.
box
!.
y
);
h
=
math
.
max
(
h
,
child
.
box
!.
height
);
}
...
...
@@ -621,7 +621,7 @@ class Table extends Widget with SpanningWidget {
);
}
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
context
.
canvas
..
saveContext
()
..
drawRect
(
...
...
@@ -636,7 +636,7 @@ class Table extends Widget with SpanningWidget {
}
index
=
0
;
for
(
var
row
in
children
)
{
for
(
final
row
in
children
)
{
if
(
index
++
<
_context
.
firstLine
&&
!
row
.
repeat
)
{
continue
;
}
...
...
@@ -644,7 +644,7 @@ class Table extends Widget with SpanningWidget {
if
(
row
.
decoration
!=
null
)
{
var
y
=
double
.
infinity
;
var
h
=
0.0
;
for
(
var
child
in
row
.
children
)
{
for
(
final
child
in
row
.
children
)
{
y
=
math
.
min
(
y
,
child
.
box
!.
y
);
h
=
math
.
max
(
h
,
child
.
box
!.
height
);
}
...
...
pdf/lib/src/widgets/text.dart
View file @
75feddd
...
...
@@ -458,16 +458,16 @@ class TextSpan extends InlineSpan {
AnnotationBuilder
?
annotation
,
)
{
final
_style
=
parentStyle
?.
merge
(
style
);
final
_a
=
this
.
annotation
??
annotation
;
final
_a
nnotation
=
this
.
annotation
??
annotation
;
if
(
text
!=
null
)
{
if
(!
visitor
(
this
,
_style
,
_a
))
{
if
(!
visitor
(
this
,
_style
,
_a
nnotation
))
{
return
false
;
}
}
if
(
children
!=
null
)
{
for
(
var
child
in
children
!)
{
if
(!
child
.
visitChildren
(
visitor
,
_style
,
_a
))
{
for
(
final
child
in
children
!)
{
if
(!
child
.
visitChildren
(
visitor
,
_style
,
_annotation
))
{
return
false
;
}
}
...
...
@@ -534,7 +534,7 @@ class _Line {
}
delta
=
(
totalWidth
-
wordsWidth
)
/
(
spans
.
length
-
1
);
var
x
=
0.0
;
for
(
var
span
in
spans
)
{
for
(
final
span
in
spans
)
{
span
.
offset
=
span
.
offset
.
translate
(
x
,
-
baseline
);
x
+=
delta
;
}
...
...
@@ -542,7 +542,7 @@ class _Line {
}
if
(
textDirection
==
TextDirection
.
rtl
)
{
for
(
var
span
in
spans
)
{
for
(
final
span
in
spans
)
{
span
.
offset
=
PdfPoint
(
totalWidth
-
(
span
.
offset
.
x
+
span
.
width
)
-
delta
,
span
.
offset
.
y
-
baseline
,
...
...
@@ -552,7 +552,7 @@ class _Line {
return
;
}
for
(
var
span
in
spans
)
{
for
(
final
span
in
spans
)
{
span
.
offset
=
span
.
offset
.
translate
(
delta
,
-
baseline
);
}
...
...
@@ -978,7 +978,7 @@ class RichText extends Widget with SpanningWidget {
..
clipPath
();
}
for
(
var
decoration
in
_decorations
)
{
for
(
final
decoration
in
_decorations
)
{
assert
(()
{
if
(
Document
.
debug
&&
RichText
.
debug
)
{
decoration
.
debugPaint
(
context
,
textScaleFactor
,
box
!,
_spans
);
...
...
@@ -994,7 +994,7 @@ class RichText extends Widget with SpanningWidget {
);
}
for
(
var
span
in
_spans
.
sublist
(
_context
.
spanStart
,
_context
.
spanEnd
))
{
for
(
final
span
in
_spans
.
sublist
(
_context
.
spanStart
,
_context
.
spanEnd
))
{
assert
(()
{
if
(
Document
.
debug
&&
RichText
.
debug
)
{
span
.
debugPaint
(
context
,
textScaleFactor
,
box
);
...
...
@@ -1018,7 +1018,7 @@ class RichText extends Widget with SpanningWidget {
);
}
for
(
var
decoration
in
_decorations
)
{
for
(
final
decoration
in
_decorations
)
{
decoration
.
foregroundPaint
(
context
,
textScaleFactor
,
...
...
pdf/lib/src/widgets/text_style.dart
View file @
75feddd
...
...
@@ -35,7 +35,7 @@ class TextDecoration {
/// Creates a decoration that paints the union of all the given decorations.
factory
TextDecoration
.
combine
(
List
<
TextDecoration
>
decorations
)
{
var
mask
=
0
;
for
(
var
decoration
in
decorations
)
{
for
(
final
decoration
in
decorations
)
{
mask
|=
decoration
.
_mask
;
}
return
TextDecoration
.
_
(
mask
);
...
...
pdf/lib/src/widgets/wrap.dart
View file @
75feddd
...
...
@@ -192,7 +192,7 @@ class Wrap extends MultiChildWidget with SpanningWidget {
var
runCrossAxisExtent
=
0.0
;
var
childCount
=
0
;
for
(
var
child
in
children
.
sublist
(
_context
.
firstChild
))
{
for
(
final
child
in
children
.
sublist
(
_context
.
firstChild
))
{
child
.
layout
(
context
,
childConstraints
,
parentUsesSize:
true
);
final
childMainAxisExtent
=
_getMainAxisExtent
(
child
)!;
...
...
@@ -339,7 +339,7 @@ class Wrap extends MultiChildWidget with SpanningWidget {
}
var
currentWidget
=
_context
.
lastChild
;
for
(
var
child
in
children
.
sublist
(
currentWidget
))
{
for
(
final
child
in
children
.
sublist
(
currentWidget
))
{
final
runIndex
=
childRunMetrics
[
child
];
if
(
runIndex
!=
i
)
{
break
;
...
...
pdf/test/arabic_test.dart
View file @
75feddd
...
...
@@ -460,7 +460,7 @@ void main() {
),
);
for
(
var
item
in
cases
)
{
for
(
final
item
in
cases
)
{
expect
(
arabic
.
convert
(
item
.
original
).
codeUnits
,
equals
(
item
.
reshaped
),
...
...
pdf/test/metrics_test.dart
View file @
75feddd
...
...
@@ -107,7 +107,7 @@ void main() {
final
fontData
=
ttfFont
.
readAsBytesSync
();
final
font
=
PdfTtfFont
(
pdf
.
document
,
fontData
.
buffer
.
asByteData
());
for
(
var
letter
in
for
(
final
letter
in
//font.font.charToGlyphIndexMap.keys
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&%!?0123456789'
.
codeUnits
)
{
...
...
pdf/test/widget_container_test.dart
View file @
75feddd
...
...
@@ -54,8 +54,8 @@ void main() {
final
image
=
generateBitmap
(
100
,
200
);
final
widgets
=
<
Widget
>[];
for
(
var
shape
in
BoxShape
.
values
)
{
for
(
var
fit
in
BoxFit
.
values
)
{
for
(
final
shape
in
BoxShape
.
values
)
{
for
(
final
fit
in
BoxFit
.
values
)
{
widgets
.
add
(
Container
(
alignment:
Alignment
.
center
,
...
...
pdf/test/widget_table_test.dart
View file @
75feddd
...
...
@@ -30,7 +30,7 @@ List<TableRow> buildTable(
final
rows
=
<
TableRow
>[];
{
final
tableRow
=
<
Widget
>[];
for
(
var
cell
in
<
String
>[
'Hue'
,
'Color'
,
'RGBA'
])
{
for
(
final
cell
in
<
String
>[
'Hue'
,
'Color'
,
'RGBA'
])
{
tableRow
.
add
(
Container
(
alignment:
Alignment
.
center
,
margin:
const
EdgeInsets
.
all
(
5
),
...
...
pdf/test/widget_text_test.dart
View file @
75feddd
...
...
@@ -32,7 +32,7 @@ Iterable<TextDecoration> permute(
List
<
TextDecoration
>
prefix
,
List
<
TextDecoration
>
remaining
)
sync
*
{
yield
TextDecoration
.
combine
(
prefix
);
if
(
remaining
.
isNotEmpty
)
{
for
(
var
decoration
in
remaining
)
{
for
(
final
decoration
in
remaining
)
{
final
next
=
List
<
TextDecoration
>.
from
(
remaining
);
next
.
remove
(
decoration
);
yield
*
permute
(
prefix
+
<
TextDecoration
>[
decoration
],
next
);
...
...
@@ -99,7 +99,7 @@ void main() {
final
para
=
LoremText
().
paragraph
(
40
);
final
widgets
=
<
Widget
>[];
for
(
var
align
in
TextAlign
.
values
)
{
for
(
final
align
in
TextAlign
.
values
)
{
widgets
.
add
(
Text
(
'
$align
:
\n
'
+
para
,
...
...
@@ -191,8 +191,8 @@ void main() {
),
);
for
(
var
decorationStyle
in
TextDecorationStyle
.
values
)
{
for
(
var
decoration
in
decorationSet
)
{
for
(
final
decorationStyle
in
TextDecorationStyle
.
values
)
{
for
(
final
decoration
in
decorationSet
)
{
widgets
.
add
(
Text
(
decoration
.
toString
().
replaceAll
(
'.'
,
' '
),
...
...
@@ -217,7 +217,7 @@ void main() {
final
para
=
LoremText
(
random:
rnd
).
paragraph
(
40
);
final
spans
=
<
TextSpan
>[];
for
(
var
word
in
para
.
split
(
' '
))
{
for
(
final
word
in
para
.
split
(
' '
))
{
spans
.
add
(
TextSpan
(
text:
word
,
...
...
pdf/test/widget_wrap_test.dart
View file @
75feddd
...
...
@@ -31,9 +31,9 @@ void main() {
test
(
'Wrap Widget Horizontal 1'
,
()
{
final
wraps
=
<
Widget
>[];
for
(
var
direction
in
VerticalDirection
.
values
)
{
for
(
final
direction
in
VerticalDirection
.
values
)
{
wraps
.
add
(
Text
(
'
$direction
'
));
for
(
var
alignment
in
WrapAlignment
.
values
)
{
for
(
final
alignment
in
WrapAlignment
.
values
)
{
wraps
.
add
(
Text
(
'
$alignment
'
));
wraps
.
add
(
Wrap
(
...
...
@@ -63,9 +63,9 @@ void main() {
test
(
'Wrap Widget Vertical 1'
,
()
{
final
wraps
=
<
Widget
>[];
for
(
var
direction
in
VerticalDirection
.
values
)
{
for
(
final
direction
in
VerticalDirection
.
values
)
{
wraps
.
add
(
Transform
.
rotateBox
(
child:
Text
(
'
$direction
'
),
angle:
1.57
));
for
(
var
alignment
in
WrapAlignment
.
values
)
{
for
(
final
alignment
in
WrapAlignment
.
values
)
{
wraps
.
add
(
Transform
.
rotateBox
(
child:
Text
(
'
$alignment
'
),
angle:
1.57
));
wraps
.
add
(
Wrap
(
...
...
@@ -95,7 +95,7 @@ void main() {
test
(
'Wrap Widget Horizontal 2'
,
()
{
final
wraps
=
<
Widget
>[];
for
(
var
alignment
in
WrapCrossAlignment
.
values
)
{
for
(
final
alignment
in
WrapCrossAlignment
.
values
)
{
final
rnd
=
math
.
Random
(
42
);
wraps
.
add
(
Text
(
'
$alignment
'
));
wraps
.
add
(
...
...
@@ -129,7 +129,7 @@ void main() {
test
(
'Wrap Widget Vertical 2'
,
()
{
final
wraps
=
<
Widget
>[];
for
(
var
alignment
in
WrapCrossAlignment
.
values
)
{
for
(
final
alignment
in
WrapCrossAlignment
.
values
)
{
final
rnd
=
math
.
Random
(
42
);
wraps
.
add
(
Transform
.
rotateBox
(
child:
Text
(
'
$alignment
'
),
angle:
1.57
));
wraps
.
add
(
...
...
@@ -163,7 +163,7 @@ void main() {
test
(
'Wrap Widget Horizontal 3'
,
()
{
final
wraps
=
<
Widget
>[];
for
(
var
alignment
in
WrapAlignment
.
values
)
{
for
(
final
alignment
in
WrapAlignment
.
values
)
{
final
rnd
=
math
.
Random
(
42
);
wraps
.
add
(
Text
(
'
$alignment
'
));
wraps
.
add
(
...
...
@@ -199,7 +199,7 @@ void main() {
test
(
'Wrap Widget Vertical 3'
,
()
{
final
wraps
=
<
Widget
>[];
for
(
var
alignment
in
WrapAlignment
.
values
)
{
for
(
final
alignment
in
WrapAlignment
.
values
)
{
final
rnd
=
math
.
Random
(
42
);
wraps
.
add
(
Transform
.
rotateBox
(
child:
Text
(
'
$alignment
'
),
angle:
1.57
));
wraps
.
add
(
...
...
Please
register
or
login
to post a comment