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-17 14:21:06 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eeab543282e1040bc63c2724b85dfa66b77544a3
eeab5432
1 parent
60a3bce9
Add Flexible and Spacer Widgets
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/flex.dart
pdf/CHANGELOG.md
View file @
eeab543
...
...
@@ -2,6 +2,7 @@
*
Deprecate the document argument in Printing.sharePdf()
*
Add default value to alpha in PdfColor variants
*
Fix Table Widget
*
Add Flexible and Spacer Widgets
# 1.3.9
*
Fix Transform Widget alignment
...
...
pdf/lib/widgets/flex.dart
View file @
eeab543
...
...
@@ -94,7 +94,7 @@ class Flex extends MultiChildWidget {
double
maxFlexFractionSoFar
=
0
;
for
(
Widget
child
in
children
)
{
final
int
flex
=
child
is
Expanded
?
child
.
flex
:
0
;
final
int
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
totalFlex
+=
flex
;
if
(
flex
>
0
)
{
final
double
flexFraction
=
childSize
(
child
,
extent
)
/
flex
;
...
...
@@ -116,7 +116,7 @@ class Flex extends MultiChildWidget {
double
inflexibleSpace
=
0
;
double
maxCrossSize
=
0
;
for
(
Widget
child
in
children
)
{
final
int
flex
=
child
is
Expanded
?
child
.
flex
:
0
;
final
int
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
totalFlex
+=
flex
;
double
mainSize
;
double
crossSize
;
...
...
@@ -143,7 +143,7 @@ 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
;
final
int
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
if
(
flex
>
0
)
{
maxCrossSize
=
math
.
max
(
maxCrossSize
,
childSize
(
child
,
spacePerFlex
*
flex
));
...
...
@@ -219,8 +219,8 @@ class Flex extends MultiChildWidget {
double
allocatedSize
=
0
;
// Sum of the sizes of the non-flexible children.
for
(
Widget
child
in
children
)
{
final
int
flex
=
child
is
Expanded
?
child
.
flex
:
0
;
final
FlexFit
fit
=
child
is
Expanded
?
child
.
fit
:
FlexFit
.
loose
;
final
int
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
final
FlexFit
fit
=
child
is
Flexible
?
child
.
fit
:
FlexFit
.
loose
;
if
(
flex
>
0
)
{
assert
(()
{
final
String
dimension
=
...
...
@@ -277,8 +277,8 @@ class Flex extends MultiChildWidget {
canFlex
&&
totalFlex
>
0
?
(
freeSpace
/
totalFlex
)
:
double
.
nan
;
for
(
Widget
child
in
children
)
{
final
int
flex
=
child
is
Expanded
?
child
.
flex
:
0
;
final
FlexFit
fit
=
child
is
Expanded
?
child
.
fit
:
FlexFit
.
loose
;
final
int
flex
=
child
is
Flexible
?
child
.
flex
:
0
;
final
FlexFit
fit
=
child
is
Flexible
?
child
.
fit
:
FlexFit
.
loose
;
if
(
flex
>
0
)
{
final
double
maxChildExtent
=
canFlex
?
(
child
==
lastFlexChild
...
...
@@ -497,15 +497,18 @@ class Column extends Flex {
);
}
class
Expanded
extends
SingleChildWidget
{
Expanded
({
/// A widget that controls how a child of a [Row], [Column], or [Flex] flexes.
class
Flexible
extends
SingleChildWidget
{
Flexible
({
this
.
flex
=
1
,
this
.
fit
=
FlexFit
.
tight
,
this
.
fit
=
FlexFit
.
loose
,
@required
Widget
child
,
})
:
super
(
child:
child
);
/// The flex factor to use for this child
final
int
flex
;
/// How a flexible child is inscribed into the available space.
final
FlexFit
fit
;
@override
...
...
@@ -515,6 +518,34 @@ class Expanded extends SingleChildWidget {
}
}
class
Expanded
extends
Flexible
{
Expanded
({
int
flex
=
1
,
FlexFit
fit
=
FlexFit
.
tight
,
@required
Widget
child
,
})
:
super
(
child:
child
,
flex:
flex
,
fit:
fit
);
}
/// Spacer creates an adjustable, empty spacer that can be used to tune the
/// spacing between widgets in a [Flex] container, like [Row] or [Column].
class
Spacer
extends
StatelessWidget
{
Spacer
({
this
.
flex
=
1
})
:
assert
(
flex
!=
null
),
assert
(
flex
>
0
),
super
();
/// The flex factor to use in determining how much space to take up.
final
int
flex
;
@override
Widget
build
(
Context
context
)
{
return
Expanded
(
flex:
flex
,
child:
SizedBox
.
shrink
(),
);
}
}
class
ListView
extends
Flex
{
ListView
(
{
Axis
direction
=
Axis
.
vertical
,
...
...
Please
register
or
login
to post a comment