David PHAM-VAN

Add Border and BorderSide objects

... ... @@ -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,
),
... ...
... ... @@ -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
... ...
... ... @@ -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,
),
... ...
... ... @@ -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()')
... ...
... ... @@ -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,
))));
... ...
... ... @@ -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: BoxBorder(
border: Border.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: BoxBorder(
border: Border.all(
color: PdfColors.blue800,
top: true,
left: true,
right: true,
bottom: true,
width: 2,
)),
width: 200,
... ...
... ... @@ -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,
),
... ...
... ... @@ -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,
... ...