David PHAM-VAN

Add all Material Colors

... ... @@ -4,6 +4,7 @@
* Add Page.orientation to force landscape or portrait
* Improve MultiPage Widget
* Convert GridView to a SpanningWidget
* Add all Material Colors
# 1.3.3
* Fix a bug with the RichText Widget
... ...
... ... @@ -20,11 +20,11 @@ void main() {
padding: const EdgeInsets.only(bottom: 3.0 * PdfPageFormat.mm),
decoration: const BoxDecoration(
border:
BoxBorder(bottom: true, width: 0.5, color: PdfColor.grey)),
BoxBorder(bottom: true, width: 0.5, color: PdfColors.grey)),
child: Text('Portable Document Format',
style: Theme.of(context)
.defaultTextStyle
.copyWith(color: PdfColor.grey)));
.copyWith(color: PdfColors.grey)));
},
footer: (Context context) {
return Container(
... ... @@ -33,7 +33,7 @@ void main() {
child: Text('Page ${context.pageNumber}',
style: Theme.of(context)
.defaultTextStyle
.copyWith(color: PdfColor.grey)));
.copyWith(color: PdfColors.grey)));
},
build: (Context context) => <Widget>[
Header(
... ...
... ... @@ -31,6 +31,7 @@ part 'src/ascii85.dart';
part 'src/border.dart';
part 'src/catalog.dart';
part 'src/color.dart';
part 'src/colors.dart';
part 'src/compatibility.dart';
part 'src/document.dart';
part 'src/font.dart';
... ...
... ... @@ -26,6 +26,9 @@ class PdfColor {
a = (color >> 24 & 0xff) / 255.0;
factory PdfColor.fromHex(String color) {
if (color.startsWith('#')) {
color = color.substring(1);
}
return PdfColor(
(int.parse(color.substring(0, 1), radix: 16) >> 16 & 0xff) / 255.0,
(int.parse(color.substring(2, 3), radix: 16) >> 8 & 0xff) / 255.0,
... ... @@ -38,27 +41,48 @@ class PdfColor {
final double g;
final double b;
static const PdfColor black = PdfColor(0.0, 0.0, 0.0);
static const PdfColor white = PdfColor(1.0, 1.0, 1.0);
static const PdfColor red = PdfColor(0.95686, 0.26274, 0.21176);
static const PdfColor pink = PdfColor(0.91372, 0.11764, 0.38823);
static const PdfColor purple = PdfColor(0.91372, 0.11764, 0.38823);
static const PdfColor deepPurple = PdfColor(0.40392, 0.22745, 0.71765);
static const PdfColor indigo = PdfColor(0.24705, 0.31765, 0.70980);
static const PdfColor blue = PdfColor(0.12941, 0.58823, 0.95294);
static const PdfColor lightBlue = PdfColor(0.01176, 0.66274, 0.95686);
static const PdfColor cyan = PdfColor(0, 0.73725, 0.83137);
static const PdfColor teal = PdfColor(0, 0.58823, 0.53333);
static const PdfColor green = PdfColor(0.29803, 0.68627, 0.31372);
static const PdfColor lightGreen = PdfColor(0.54509, 0.76470, 0.29020);
static const PdfColor lime = PdfColor(0.80392, 0.86274, 0.22353);
static const PdfColor yellow = PdfColor(1, 0.92157, 0.23137);
static const PdfColor amber = PdfColor(1, 0.75686, 0.02745);
static const PdfColor orange = PdfColor(1, 0.59608, 0);
static const PdfColor deepOrange = PdfColor(1, 0.34118, 0.13333);
static const PdfColor brown = PdfColor(0.47451, 0.33333, 0.28235);
static const PdfColor grey = PdfColor(0.61961, 0.61961, 0.61961);
static const PdfColor blueGrey = PdfColor(0.37647, 0.49020, 0.54510);
@deprecated
static const PdfColor black = PdfColors.black;
@deprecated
static const PdfColor white = PdfColors.white;
@deprecated
static const PdfColor red = PdfColors.red;
@deprecated
static const PdfColor pink = PdfColors.pink;
@deprecated
static const PdfColor purple = PdfColors.purple;
@deprecated
static const PdfColor deepPurple = PdfColors.deepPurple;
@deprecated
static const PdfColor indigo = PdfColors.indigo;
@deprecated
static const PdfColor blue = PdfColors.blue;
@deprecated
static const PdfColor lightBlue = PdfColors.lightBlue;
@deprecated
static const PdfColor cyan = PdfColors.cyan;
@deprecated
static const PdfColor teal = PdfColors.teal;
@deprecated
static const PdfColor green = PdfColors.green;
@deprecated
static const PdfColor lightGreen = PdfColors.lightGreen;
@deprecated
static const PdfColor lime = PdfColors.lime;
@deprecated
static const PdfColor yellow = PdfColors.yellow;
@deprecated
static const PdfColor amber = PdfColors.amber;
@deprecated
static const PdfColor orange = PdfColors.orange;
@deprecated
static const PdfColor deepOrange = PdfColors.deepOrange;
@deprecated
static const PdfColor brown = PdfColors.brown;
@deprecated
static const PdfColor grey = PdfColors.grey;
@deprecated
static const PdfColor blueGrey = PdfColors.blueGrey;
int toInt() =>
((((a * 255.0).round() & 0xff) << 24) |
... ... @@ -67,6 +91,8 @@ class PdfColor {
(((b * 255.0).round() & 0xff) << 0)) &
0xFFFFFFFF;
String toHex() => '#' + toInt().toRadixString(16);
PdfColorCmyk toCmyk() {
return PdfColorCmyk.fromRgb(r, g, b, a);
}
... ...
/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http: //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
part of pdf;
class PdfColors {
PdfColors._();
// Red
static const PdfColor red = red500;
static const PdfColor red50 = PdfColor.fromInt(0xffffebee);
static const PdfColor red100 = PdfColor.fromInt(0xffffcdd2);
static const PdfColor red200 = PdfColor.fromInt(0xffef9a9a);
static const PdfColor red300 = PdfColor.fromInt(0xffe57373);
static const PdfColor red400 = PdfColor.fromInt(0xffef5350);
static const PdfColor red500 = PdfColor.fromInt(0xfff44336);
static const PdfColor red600 = PdfColor.fromInt(0xffe53935);
static const PdfColor red700 = PdfColor.fromInt(0xffd32f2f);
static const PdfColor red800 = PdfColor.fromInt(0xffc62828);
static const PdfColor red900 = PdfColor.fromInt(0xffb71c1c);
static const PdfColor redAccent = redAccent200;
static const PdfColor redAccent100 = PdfColor.fromInt(0xffff8a80);
static const PdfColor redAccent200 = PdfColor.fromInt(0xffff5252);
static const PdfColor redAccent400 = PdfColor.fromInt(0xffff1744);
static const PdfColor redAccent700 = PdfColor.fromInt(0xffd50000);
// Pink
static const PdfColor pink = pink500;
static const PdfColor pink50 = PdfColor.fromInt(0xfffce4ec);
static const PdfColor pink100 = PdfColor.fromInt(0xfff8bbd0);
static const PdfColor pink200 = PdfColor.fromInt(0xfff48fb1);
static const PdfColor pink300 = PdfColor.fromInt(0xfff06292);
static const PdfColor pink400 = PdfColor.fromInt(0xffec407a);
static const PdfColor pink500 = PdfColor.fromInt(0xffe91e63);
static const PdfColor pink600 = PdfColor.fromInt(0xffd81b60);
static const PdfColor pink700 = PdfColor.fromInt(0xffc2185b);
static const PdfColor pink800 = PdfColor.fromInt(0xffad1457);
static const PdfColor pink900 = PdfColor.fromInt(0xff880e4f);
static const PdfColor pinkAccent = pinkAccent200;
static const PdfColor pinkAccent100 = PdfColor.fromInt(0xffff80ab);
static const PdfColor pinkAccent200 = PdfColor.fromInt(0xffff4081);
static const PdfColor pinkAccent400 = PdfColor.fromInt(0xfff50057);
static const PdfColor pinkAccent700 = PdfColor.fromInt(0xffc51162);
// Purple
static const PdfColor purple = purple500;
static const PdfColor purple50 = PdfColor.fromInt(0xfff3e5f5);
static const PdfColor purple100 = PdfColor.fromInt(0xffe1bee7);
static const PdfColor purple200 = PdfColor.fromInt(0xffce93d8);
static const PdfColor purple300 = PdfColor.fromInt(0xffba68c8);
static const PdfColor purple400 = PdfColor.fromInt(0xffab47bc);
static const PdfColor purple500 = PdfColor.fromInt(0xff9c27b0);
static const PdfColor purple600 = PdfColor.fromInt(0xff8e24aa);
static const PdfColor purple700 = PdfColor.fromInt(0xff7b1fa2);
static const PdfColor purple800 = PdfColor.fromInt(0xff6a1b9a);
static const PdfColor purple900 = PdfColor.fromInt(0xff4a148c);
static const PdfColor purpleAccent = purpleAccent200;
static const PdfColor purpleAccent100 = PdfColor.fromInt(0xffea80fc);
static const PdfColor purpleAccent200 = PdfColor.fromInt(0xffe040fb);
static const PdfColor purpleAccent400 = PdfColor.fromInt(0xffd500f9);
static const PdfColor purpleAccent700 = PdfColor.fromInt(0xffaa00ff);
// Deep Purple
static const PdfColor deepPurple = deepPurple500;
static const PdfColor deepPurple50 = PdfColor.fromInt(0xffede7f6);
static const PdfColor deepPurple100 = PdfColor.fromInt(0xffd1c4e9);
static const PdfColor deepPurple200 = PdfColor.fromInt(0xffb39ddb);
static const PdfColor deepPurple300 = PdfColor.fromInt(0xff9575cd);
static const PdfColor deepPurple400 = PdfColor.fromInt(0xff7e57c2);
static const PdfColor deepPurple500 = PdfColor.fromInt(0xff673ab7);
static const PdfColor deepPurple600 = PdfColor.fromInt(0xff5e35b1);
static const PdfColor deepPurple700 = PdfColor.fromInt(0xff512da8);
static const PdfColor deepPurple800 = PdfColor.fromInt(0xff4527a0);
static const PdfColor deepPurple900 = PdfColor.fromInt(0xff311b92);
static const PdfColor deepPurpleAccent = deepPurpleAccent200;
static const PdfColor deepPurpleAccent100 = PdfColor.fromInt(0xffb388ff);
static const PdfColor deepPurpleAccent200 = PdfColor.fromInt(0xff7c4dff);
static const PdfColor deepPurpleAccent400 = PdfColor.fromInt(0xff651fff);
static const PdfColor deepPurpleAccent700 = PdfColor.fromInt(0xff6200ea);
// Indigo
static const PdfColor indigo = indigo500;
static const PdfColor indigo50 = PdfColor.fromInt(0xffe8eaf6);
static const PdfColor indigo100 = PdfColor.fromInt(0xffc5cae9);
static const PdfColor indigo200 = PdfColor.fromInt(0xff9fa8da);
static const PdfColor indigo300 = PdfColor.fromInt(0xff7986cb);
static const PdfColor indigo400 = PdfColor.fromInt(0xff5c6bc0);
static const PdfColor indigo500 = PdfColor.fromInt(0xff3f51b5);
static const PdfColor indigo600 = PdfColor.fromInt(0xff3949ab);
static const PdfColor indigo700 = PdfColor.fromInt(0xff303f9f);
static const PdfColor indigo800 = PdfColor.fromInt(0xff283593);
static const PdfColor indigo900 = PdfColor.fromInt(0xff1a237e);
static const PdfColor indigoAccent = indigoAccent200;
static const PdfColor indigoAccent100 = PdfColor.fromInt(0xff8c9eff);
static const PdfColor indigoAccent200 = PdfColor.fromInt(0xff536dfe);
static const PdfColor indigoAccent400 = PdfColor.fromInt(0xff3d5afe);
static const PdfColor indigoAccent700 = PdfColor.fromInt(0xff304ffe);
// Blue
static const PdfColor blue = blue500;
static const PdfColor blue50 = PdfColor.fromInt(0xffe3f2fd);
static const PdfColor blue100 = PdfColor.fromInt(0xffbbdefb);
static const PdfColor blue200 = PdfColor.fromInt(0xff90caf9);
static const PdfColor blue300 = PdfColor.fromInt(0xff64b5f6);
static const PdfColor blue400 = PdfColor.fromInt(0xff42a5f5);
static const PdfColor blue500 = PdfColor.fromInt(0xff2196f3);
static const PdfColor blue600 = PdfColor.fromInt(0xff1e88e5);
static const PdfColor blue700 = PdfColor.fromInt(0xff1976d2);
static const PdfColor blue800 = PdfColor.fromInt(0xff1565c0);
static const PdfColor blue900 = PdfColor.fromInt(0xff0d47a1);
static const PdfColor blueAccent = blueAccent200;
static const PdfColor blueAccent100 = PdfColor.fromInt(0xff82b1ff);
static const PdfColor blueAccent200 = PdfColor.fromInt(0xff448aff);
static const PdfColor blueAccent400 = PdfColor.fromInt(0xff2979ff);
static const PdfColor blueAccent700 = PdfColor.fromInt(0xff2962ff);
// Light Blue
static const PdfColor lightBlue = lightBlue500;
static const PdfColor lightBlue50 = PdfColor.fromInt(0xffe1f5fe);
static const PdfColor lightBlue100 = PdfColor.fromInt(0xffb3e5fc);
static const PdfColor lightBlue200 = PdfColor.fromInt(0xff81d4fa);
static const PdfColor lightBlue300 = PdfColor.fromInt(0xff4fc3f7);
static const PdfColor lightBlue400 = PdfColor.fromInt(0xff29b6f6);
static const PdfColor lightBlue500 = PdfColor.fromInt(0xff03a9f4);
static const PdfColor lightBlue600 = PdfColor.fromInt(0xff039be5);
static const PdfColor lightBlue700 = PdfColor.fromInt(0xff0288d1);
static const PdfColor lightBlue800 = PdfColor.fromInt(0xff0277bd);
static const PdfColor lightBlue900 = PdfColor.fromInt(0xff01579b);
static const PdfColor lightBlueAccent = lightBlueAccent200;
static const PdfColor lightBlueAccent100 = PdfColor.fromInt(0xff80d8ff);
static const PdfColor lightBlueAccent200 = PdfColor.fromInt(0xff40c4ff);
static const PdfColor lightBlueAccent400 = PdfColor.fromInt(0xff00b0ff);
static const PdfColor lightBlueAccent700 = PdfColor.fromInt(0xff0091ea);
// Cyan
static const PdfColor cyan = cyan500;
static const PdfColor cyan50 = PdfColor.fromInt(0xffe0f7fa);
static const PdfColor cyan100 = PdfColor.fromInt(0xffb2ebf2);
static const PdfColor cyan200 = PdfColor.fromInt(0xff80deea);
static const PdfColor cyan300 = PdfColor.fromInt(0xff4dd0e1);
static const PdfColor cyan400 = PdfColor.fromInt(0xff26c6da);
static const PdfColor cyan500 = PdfColor.fromInt(0xff00bcd4);
static const PdfColor cyan600 = PdfColor.fromInt(0xff00acc1);
static const PdfColor cyan700 = PdfColor.fromInt(0xff0097a7);
static const PdfColor cyan800 = PdfColor.fromInt(0xff00838f);
static const PdfColor cyan900 = PdfColor.fromInt(0xff006064);
static const PdfColor cyanAccent = cyanAccent200;
static const PdfColor cyanAccent100 = PdfColor.fromInt(0xff84ffff);
static const PdfColor cyanAccent200 = PdfColor.fromInt(0xff18ffff);
static const PdfColor cyanAccent400 = PdfColor.fromInt(0xff00e5ff);
static const PdfColor cyanAccent700 = PdfColor.fromInt(0xff00b8d4);
// Teal
static const PdfColor teal = teal500;
static const PdfColor teal50 = PdfColor.fromInt(0xffe0f2f1);
static const PdfColor teal100 = PdfColor.fromInt(0xffb2dfdb);
static const PdfColor teal200 = PdfColor.fromInt(0xff80cbc4);
static const PdfColor teal300 = PdfColor.fromInt(0xff4db6ac);
static const PdfColor teal400 = PdfColor.fromInt(0xff26a69a);
static const PdfColor teal500 = PdfColor.fromInt(0xff009688);
static const PdfColor teal600 = PdfColor.fromInt(0xff00897b);
static const PdfColor teal700 = PdfColor.fromInt(0xff00796b);
static const PdfColor teal800 = PdfColor.fromInt(0xff00695c);
static const PdfColor teal900 = PdfColor.fromInt(0xff004d40);
static const PdfColor tealAccent = tealAccent200;
static const PdfColor tealAccent100 = PdfColor.fromInt(0xffa7ffeb);
static const PdfColor tealAccent200 = PdfColor.fromInt(0xff64ffda);
static const PdfColor tealAccent400 = PdfColor.fromInt(0xff1de9b6);
static const PdfColor tealAccent700 = PdfColor.fromInt(0xff00bfa5);
// Green
static const PdfColor green = green500;
static const PdfColor green50 = PdfColor.fromInt(0xffe8f5e9);
static const PdfColor green100 = PdfColor.fromInt(0xffc8e6c9);
static const PdfColor green200 = PdfColor.fromInt(0xffa5d6a7);
static const PdfColor green300 = PdfColor.fromInt(0xff81c784);
static const PdfColor green400 = PdfColor.fromInt(0xff66bb6a);
static const PdfColor green500 = PdfColor.fromInt(0xff4caf50);
static const PdfColor green600 = PdfColor.fromInt(0xff43a047);
static const PdfColor green700 = PdfColor.fromInt(0xff388e3c);
static const PdfColor green800 = PdfColor.fromInt(0xff2e7d32);
static const PdfColor green900 = PdfColor.fromInt(0xff1b5e20);
static const PdfColor greenAccent = greenAccent200;
static const PdfColor greenAccent100 = PdfColor.fromInt(0xffb9f6ca);
static const PdfColor greenAccent200 = PdfColor.fromInt(0xff69f0ae);
static const PdfColor greenAccent400 = PdfColor.fromInt(0xff00e676);
static const PdfColor greenAccent700 = PdfColor.fromInt(0xff00c853);
// Light Green
static const PdfColor lightGreen = lightGreen500;
static const PdfColor lightGreen50 = PdfColor.fromInt(0xfff1f8e9);
static const PdfColor lightGreen100 = PdfColor.fromInt(0xffdcedc8);
static const PdfColor lightGreen200 = PdfColor.fromInt(0xffc5e1a5);
static const PdfColor lightGreen300 = PdfColor.fromInt(0xffaed581);
static const PdfColor lightGreen400 = PdfColor.fromInt(0xff9ccc65);
static const PdfColor lightGreen500 = PdfColor.fromInt(0xff8bc34a);
static const PdfColor lightGreen600 = PdfColor.fromInt(0xff7cb342);
static const PdfColor lightGreen700 = PdfColor.fromInt(0xff689f38);
static const PdfColor lightGreen800 = PdfColor.fromInt(0xff558b2f);
static const PdfColor lightGreen900 = PdfColor.fromInt(0xff33691e);
static const PdfColor lightGreenAccent = lightGreenAccent200;
static const PdfColor lightGreenAccent100 = PdfColor.fromInt(0xffccff90);
static const PdfColor lightGreenAccent200 = PdfColor.fromInt(0xffb2ff59);
static const PdfColor lightGreenAccent400 = PdfColor.fromInt(0xff76ff03);
static const PdfColor lightGreenAccent700 = PdfColor.fromInt(0xff64dd17);
// Lime
static const PdfColor lime = lime500;
static const PdfColor lime50 = PdfColor.fromInt(0xfff9fbe7);
static const PdfColor lime100 = PdfColor.fromInt(0xfff0f4c3);
static const PdfColor lime200 = PdfColor.fromInt(0xffe6ee9c);
static const PdfColor lime300 = PdfColor.fromInt(0xffdce775);
static const PdfColor lime400 = PdfColor.fromInt(0xffd4e157);
static const PdfColor lime500 = PdfColor.fromInt(0xffcddc39);
static const PdfColor lime600 = PdfColor.fromInt(0xffc0ca33);
static const PdfColor lime700 = PdfColor.fromInt(0xffafb42b);
static const PdfColor lime800 = PdfColor.fromInt(0xff9e9d24);
static const PdfColor lime900 = PdfColor.fromInt(0xff827717);
static const PdfColor limeAccent = limeAccent200;
static const PdfColor limeAccent100 = PdfColor.fromInt(0xfff4ff81);
static const PdfColor limeAccent200 = PdfColor.fromInt(0xffeeff41);
static const PdfColor limeAccent400 = PdfColor.fromInt(0xffc6ff00);
static const PdfColor limeAccent700 = PdfColor.fromInt(0xffaeea00);
// Yellow
static const PdfColor yellow = yellow500;
static const PdfColor yellow50 = PdfColor.fromInt(0xfffffde7);
static const PdfColor yellow100 = PdfColor.fromInt(0xfffff9c4);
static const PdfColor yellow200 = PdfColor.fromInt(0xfffff59d);
static const PdfColor yellow300 = PdfColor.fromInt(0xfffff176);
static const PdfColor yellow400 = PdfColor.fromInt(0xffffee58);
static const PdfColor yellow500 = PdfColor.fromInt(0xffffeb3b);
static const PdfColor yellow600 = PdfColor.fromInt(0xfffdd835);
static const PdfColor yellow700 = PdfColor.fromInt(0xfffbc02d);
static const PdfColor yellow800 = PdfColor.fromInt(0xfff9a825);
static const PdfColor yellow900 = PdfColor.fromInt(0xfff57f17);
static const PdfColor yellowAccent = yellowAccent200;
static const PdfColor yellowAccent100 = PdfColor.fromInt(0xffffff8d);
static const PdfColor yellowAccent200 = PdfColor.fromInt(0xffffff00);
static const PdfColor yellowAccent400 = PdfColor.fromInt(0xffffea00);
static const PdfColor yellowAccent700 = PdfColor.fromInt(0xffffd600);
// Amber
static const PdfColor amber = amber500;
static const PdfColor amber50 = PdfColor.fromInt(0xfffff8e1);
static const PdfColor amber100 = PdfColor.fromInt(0xffffecb3);
static const PdfColor amber200 = PdfColor.fromInt(0xffffe082);
static const PdfColor amber300 = PdfColor.fromInt(0xffffd54f);
static const PdfColor amber400 = PdfColor.fromInt(0xffffca28);
static const PdfColor amber500 = PdfColor.fromInt(0xffffc107);
static const PdfColor amber600 = PdfColor.fromInt(0xffffb300);
static const PdfColor amber700 = PdfColor.fromInt(0xffffa000);
static const PdfColor amber800 = PdfColor.fromInt(0xffff8f00);
static const PdfColor amber900 = PdfColor.fromInt(0xffff6f00);
static const PdfColor amberAccent = amberAccent200;
static const PdfColor amberAccent100 = PdfColor.fromInt(0xffffe57f);
static const PdfColor amberAccent200 = PdfColor.fromInt(0xffffd740);
static const PdfColor amberAccent400 = PdfColor.fromInt(0xffffc400);
static const PdfColor amberAccent700 = PdfColor.fromInt(0xffffab00);
// Orange
static const PdfColor orange = orange500;
static const PdfColor orange50 = PdfColor.fromInt(0xfffff3e0);
static const PdfColor orange100 = PdfColor.fromInt(0xffffe0b2);
static const PdfColor orange200 = PdfColor.fromInt(0xffffcc80);
static const PdfColor orange300 = PdfColor.fromInt(0xffffb74d);
static const PdfColor orange400 = PdfColor.fromInt(0xffffa726);
static const PdfColor orange500 = PdfColor.fromInt(0xffff9800);
static const PdfColor orange600 = PdfColor.fromInt(0xfffb8c00);
static const PdfColor orange700 = PdfColor.fromInt(0xfff57c00);
static const PdfColor orange800 = PdfColor.fromInt(0xffef6c00);
static const PdfColor orange900 = PdfColor.fromInt(0xffe65100);
static const PdfColor orangeAccent = orangeAccent200;
static const PdfColor orangeAccent100 = PdfColor.fromInt(0xffffd180);
static const PdfColor orangeAccent200 = PdfColor.fromInt(0xffffab40);
static const PdfColor orangeAccent400 = PdfColor.fromInt(0xffff9100);
static const PdfColor orangeAccent700 = PdfColor.fromInt(0xffff6d00);
// Deep Orange
static const PdfColor deepOrange = deepOrange500;
static const PdfColor deepOrange50 = PdfColor.fromInt(0xfffbe9e7);
static const PdfColor deepOrange100 = PdfColor.fromInt(0xffffccbc);
static const PdfColor deepOrange200 = PdfColor.fromInt(0xffffab91);
static const PdfColor deepOrange300 = PdfColor.fromInt(0xffff8a65);
static const PdfColor deepOrange400 = PdfColor.fromInt(0xffff7043);
static const PdfColor deepOrange500 = PdfColor.fromInt(0xffff5722);
static const PdfColor deepOrange600 = PdfColor.fromInt(0xfff4511e);
static const PdfColor deepOrange700 = PdfColor.fromInt(0xffe64a19);
static const PdfColor deepOrange800 = PdfColor.fromInt(0xffd84315);
static const PdfColor deepOrange900 = PdfColor.fromInt(0xffbf360c);
static const PdfColor deepOrangeAccent = deepOrangeAccent200;
static const PdfColor deepOrangeAccent100 = PdfColor.fromInt(0xffff9e80);
static const PdfColor deepOrangeAccent200 = PdfColor.fromInt(0xffff6e40);
static const PdfColor deepOrangeAccent400 = PdfColor.fromInt(0xffff3d00);
static const PdfColor deepOrangeAccent700 = PdfColor.fromInt(0xffdd2c00);
// Brown
static const PdfColor brown = brown500;
static const PdfColor brown50 = PdfColor.fromInt(0xffefebe9);
static const PdfColor brown100 = PdfColor.fromInt(0xffd7ccc8);
static const PdfColor brown200 = PdfColor.fromInt(0xffbcaaa4);
static const PdfColor brown300 = PdfColor.fromInt(0xffa1887f);
static const PdfColor brown400 = PdfColor.fromInt(0xff8d6e63);
static const PdfColor brown500 = PdfColor.fromInt(0xff795548);
static const PdfColor brown600 = PdfColor.fromInt(0xff6d4c41);
static const PdfColor brown700 = PdfColor.fromInt(0xff5d4037);
static const PdfColor brown800 = PdfColor.fromInt(0xff4e342e);
static const PdfColor brown900 = PdfColor.fromInt(0xff3e2723);
// Grey
static const PdfColor grey = grey500;
static const PdfColor grey50 = PdfColor.fromInt(0xfffafafa);
static const PdfColor grey100 = PdfColor.fromInt(0xfff5f5f5);
static const PdfColor grey200 = PdfColor.fromInt(0xffeeeeee);
static const PdfColor grey300 = PdfColor.fromInt(0xffe0e0e0);
static const PdfColor grey400 = PdfColor.fromInt(0xffbdbdbd);
static const PdfColor grey500 = PdfColor.fromInt(0xff9e9e9e);
static const PdfColor grey600 = PdfColor.fromInt(0xff757575);
static const PdfColor grey700 = PdfColor.fromInt(0xff616161);
static const PdfColor grey800 = PdfColor.fromInt(0xff424242);
static const PdfColor grey900 = PdfColor.fromInt(0xff212121);
// Blue Grey
static const PdfColor blueGrey = blueGrey500;
static const PdfColor blueGrey50 = PdfColor.fromInt(0xffeceff1);
static const PdfColor blueGrey100 = PdfColor.fromInt(0xffcfd8dc);
static const PdfColor blueGrey200 = PdfColor.fromInt(0xffb0bec5);
static const PdfColor blueGrey300 = PdfColor.fromInt(0xff90a4ae);
static const PdfColor blueGrey400 = PdfColor.fromInt(0xff78909c);
static const PdfColor blueGrey500 = PdfColor.fromInt(0xff607d8b);
static const PdfColor blueGrey600 = PdfColor.fromInt(0xff546e7a);
static const PdfColor blueGrey700 = PdfColor.fromInt(0xff455a64);
static const PdfColor blueGrey800 = PdfColor.fromInt(0xff37474f);
static const PdfColor blueGrey900 = PdfColor.fromInt(0xff263238);
// White / Black
static const PdfColor white = PdfColor.fromInt(0xffffffff);
static const PdfColor black = PdfColor.fromInt(0xff000000);
/// The material design primary color swatches, excluding grey.
static const List<PdfColor> primaries = <PdfColor>[
red,
pink,
purple,
deepPurple,
indigo,
blue,
lightBlue,
cyan,
teal,
green,
lightGreen,
lime,
yellow,
amber,
orange,
deepOrange,
brown,
grey,
blueGrey,
];
/// The material design accent color swatches.
static const List<PdfColor> accents = <PdfColor>[
redAccent,
pinkAccent,
purpleAccent,
deepPurpleAccent,
indigoAccent,
blueAccent,
lightBlueAccent,
cyanAccent,
tealAccent,
greenAccent,
lightGreenAccent,
limeAccent,
yellowAccent,
amberAccent,
orangeAccent,
deepOrangeAccent,
];
}
... ...
... ... @@ -87,7 +87,7 @@ class Padding extends SingleChildWidget {
@override
void debugPaint(Context context) {
context.canvas
..setFillColor(PdfColor.lime)
..setFillColor(PdfColors.lime)
..moveTo(box.x, box.y)
..lineTo(box.right, box.y)
..lineTo(box.right, box.top)
... ...
... ... @@ -22,7 +22,7 @@ class ClipRect extends SingleChildWidget {
@override
void debugPaint(Context context) {
context.canvas
..setStrokeColor(PdfColor.deepPurple)
..setStrokeColor(PdfColors.deepPurple)
..drawRect(box.x, box.y, box.width, box.height)
..strokePath();
}
... ... @@ -63,7 +63,7 @@ class ClipRRect extends SingleChildWidget {
@override
void debugPaint(Context context) {
context.canvas
..setStrokeColor(PdfColor.deepPurple)
..setStrokeColor(PdfColors.deepPurple)
..drawRRect(
box.x, box.y, box.width, box.height, horizontalRadius, verticalRadius)
..strokePath();
... ... @@ -102,7 +102,7 @@ class ClipOval extends SingleChildWidget {
final double ry = box.height / 2.0;
context.canvas
..setStrokeColor(PdfColor.deepPurple)
..setStrokeColor(PdfColors.deepPurple)
..drawEllipse(box.x + rx, box.y + ry, rx, ry)
..strokePath();
}
... ...
... ... @@ -25,7 +25,7 @@ class BoxBorder {
this.top = false,
this.right = false,
this.bottom = false,
this.color = PdfColor.black,
this.color = PdfColors.black,
this.width = 1.0})
: assert(color != null),
assert(width != null),
... ...
... ... @@ -139,7 +139,7 @@ class Bullet extends StatelessWidget {
right: 2.0 * PdfPageFormat.mm,
),
this.bulletShape = BoxShape.circle,
this.bulletColor = PdfColor.black});
this.bulletColor = PdfColors.black});
final String text;
... ...
... ... @@ -105,7 +105,7 @@ class Page {
void debugPaint(Context context) {
final EdgeInsets _margin = margin;
context.canvas
..setFillColor(PdfColor.lightGreen)
..setFillColor(PdfColors.lightGreen)
..moveTo(0, 0)
..lineTo(pageFormat.width, 0)
..lineTo(pageFormat.width, pageFormat.height)
... ...
... ... @@ -207,7 +207,7 @@ class GridView extends MultiChildWidget implements SpanningWidget {
super.debugPaint(context);
context.canvas
..setFillColor(PdfColor.lime)
..setFillColor(PdfColors.lime)
..moveTo(box.left, box.bottom)
..lineTo(box.right, box.bottom)
..lineTo(box.right, box.top)
... ...
... ... @@ -61,7 +61,7 @@ class Placeholder extends Widget {
}
class PdfLogo extends StatelessWidget {
PdfLogo({this.color = PdfColor.red, this.fit = BoxFit.contain});
PdfLogo({this.color = PdfColors.red, this.fit = BoxFit.contain});
final PdfColor color;
final BoxFit fit;
... ...
... ... @@ -40,7 +40,7 @@ class TableBorder extends BoxBorder {
bool bottom = true,
this.horizontalInside = true,
this.verticalInside = true,
PdfColor color = PdfColor.black,
PdfColor color = PdfColors.black,
double width = 1.0})
: super(
left: left,
... ...
... ... @@ -40,14 +40,14 @@ class _Word {
context.canvas
..drawRect(globalBox.x + offset.x + metrics.left,
globalBox.top + offset.y + metrics.top, metrics.width, metrics.height)
..setStrokeColor(PdfColor.orange)
..setStrokeColor(PdfColors.orange)
..strokePath()
..drawLine(
globalBox.x + offset.x - deb,
globalBox.top + offset.y,
globalBox.x + offset.x + metrics.right + deb,
globalBox.top + offset.y)
..setStrokeColor(PdfColor.deepPurple)
..setStrokeColor(PdfColors.deepPurple)
..strokePath();
}
}
... ... @@ -237,7 +237,7 @@ class RichText extends Widget {
@override
void debugPaint(Context context) {
context.canvas
..setStrokeColor(PdfColor.blue)
..setStrokeColor(PdfColors.blue)
..drawRect(box.x, box.y, box.width, box.height)
..strokePath();
}
... ...
... ... @@ -19,7 +19,7 @@ part of widget;
@immutable
class TextStyle {
const TextStyle({
this.color = PdfColor.black,
this.color = PdfColors.black,
@required this.font,
this.fontSize = _defaultFontSize,
this.letterSpacing = 1.0,
... ...
... ... @@ -86,7 +86,7 @@ abstract class Widget {
@protected
void debugPaint(Context context) {
context.canvas
..setStrokeColor(PdfColor.purple)
..setStrokeColor(PdfColors.purple)
..drawRect(box.x, box.y, box.width, box.height)
..strokePath();
}
... ...
/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'dart:io';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
class Color extends StatelessWidget {
Color(this.color, this.name, [this.varient]);
final PdfColor color;
final String name;
final String varient;
@override
Widget build(Context context) {
final TextStyle style = Theme.of(context).defaultTextStyle.copyWith(
color: color.luminance < 0.2 ? PdfColors.white : PdfColors.black,
fontSize: 14);
final TextStyle hexStyle =
style.copyWith(font: Font.courier(), fontSize: 10);
return Container(
color: color,
padding: const EdgeInsets.all(2 * PdfPageFormat.mm),
// child: FittedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(name, style: style),
Text(varient ?? '', style: style),
Padding(padding: const EdgeInsets.all(2 * PdfPageFormat.mm)),
Text(color.toHex(), style: hexStyle),
],
// )
));
}
}
void main() {
test('Pdf', () {
final Document pdf = Document(title: 'Material Colors');
pdf.addPage(MultiPage(
pageFormat: PdfPageFormat.standard,
build: (Context context) => <Widget>[
Header(text: 'Red'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.red50, 'Red', '50'),
Color(PdfColors.red100, 'Red', '100'),
Color(PdfColors.red200, 'Red', '200'),
Color(PdfColors.red300, 'Red', '300'),
Color(PdfColors.red400, 'Red', '400'),
Color(PdfColors.red500, 'Red', '500'),
Color(PdfColors.red600, 'Red', '600'),
Color(PdfColors.red700, 'Red', '700'),
Color(PdfColors.red800, 'Red', '800'),
Color(PdfColors.red900, 'Red', '900'),
Color(PdfColors.redAccent100, 'Red', 'Accent 100'),
Color(PdfColors.redAccent200, 'Red', 'Accent 200'),
Color(PdfColors.redAccent400, 'Red', 'Accent 400'),
Color(PdfColors.redAccent700, 'Red', 'Accent 700'),
]),
NewPage(),
Header(text: 'Pink'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.pink50, 'Pink', '50'),
Color(PdfColors.pink100, 'Pink', '100'),
Color(PdfColors.pink200, 'Pink', '200'),
Color(PdfColors.pink300, 'Pink', '300'),
Color(PdfColors.pink400, 'Pink', '400'),
Color(PdfColors.pink500, 'Pink', '500'),
Color(PdfColors.pink600, 'Pink', '600'),
Color(PdfColors.pink700, 'Pink', '700'),
Color(PdfColors.pink800, 'Pink', '800'),
Color(PdfColors.pink900, 'Pink', '900'),
Color(PdfColors.pinkAccent100, 'Pink', 'Accent 100'),
Color(PdfColors.pinkAccent200, 'Pink', 'Accent 200'),
Color(PdfColors.pinkAccent400, 'Pink', 'Accent 400'),
Color(PdfColors.pinkAccent700, 'Pink', 'Accent 700'),
]),
NewPage(),
Header(text: 'Purple'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.purple50, 'Purple', '50'),
Color(PdfColors.purple100, 'Purple', '100'),
Color(PdfColors.purple200, 'Purple', '200'),
Color(PdfColors.purple300, 'Purple', '300'),
Color(PdfColors.purple400, 'Purple', '400'),
Color(PdfColors.purple500, 'Purple', '500'),
Color(PdfColors.purple600, 'Purple', '600'),
Color(PdfColors.purple700, 'Purple', '700'),
Color(PdfColors.purple800, 'Purple', '800'),
Color(PdfColors.purple900, 'Purple', '900'),
Color(PdfColors.purpleAccent100, 'Purple', 'Accent 100'),
Color(PdfColors.purpleAccent200, 'Purple', 'Accent 200'),
Color(PdfColors.purpleAccent400, 'Purple', 'Accent 400'),
Color(PdfColors.purpleAccent700, 'Purple', 'Accent 700'),
]),
NewPage(),
Header(text: 'Deep Purple'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.deepPurple50, 'Deep Purple', '50'),
Color(PdfColors.deepPurple100, 'Deep Purple', '100'),
Color(PdfColors.deepPurple200, 'Deep Purple', '200'),
Color(PdfColors.deepPurple300, 'Deep Purple', '300'),
Color(PdfColors.deepPurple400, 'Deep Purple', '400'),
Color(PdfColors.deepPurple500, 'Deep Purple', '500'),
Color(PdfColors.deepPurple600, 'Deep Purple', '600'),
Color(PdfColors.deepPurple700, 'Deep Purple', '700'),
Color(PdfColors.deepPurple800, 'Deep Purple', '800'),
Color(PdfColors.deepPurple900, 'Deep Purple', '900'),
Color(PdfColors.deepPurpleAccent100, 'Deep Purple',
'Accent 100'),
Color(PdfColors.deepPurpleAccent200, 'Deep Purple',
'Accent 200'),
Color(PdfColors.deepPurpleAccent400, 'Deep Purple',
'Accent 400'),
Color(PdfColors.deepPurpleAccent700, 'Deep Purple',
'Accent 700'),
]),
NewPage(),
Header(text: 'Indigo'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.indigo50, 'Indigo', '50'),
Color(PdfColors.indigo100, 'Indigo', '100'),
Color(PdfColors.indigo200, 'Indigo', '200'),
Color(PdfColors.indigo300, 'Indigo', '300'),
Color(PdfColors.indigo400, 'Indigo', '400'),
Color(PdfColors.indigo500, 'Indigo', '500'),
Color(PdfColors.indigo600, 'Indigo', '600'),
Color(PdfColors.indigo700, 'Indigo', '700'),
Color(PdfColors.indigo800, 'Indigo', '800'),
Color(PdfColors.indigo900, 'Indigo', '900'),
Color(PdfColors.indigoAccent100, 'Indigo', 'Accent 100'),
Color(PdfColors.indigoAccent200, 'Indigo', 'Accent 200'),
Color(PdfColors.indigoAccent400, 'Indigo', 'Accent 400'),
Color(PdfColors.indigoAccent700, 'Indigo', 'Accent 700'),
]),
NewPage(),
Header(text: 'Blue'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.blue50, 'Blue', '50'),
Color(PdfColors.blue100, 'Blue', '100'),
Color(PdfColors.blue200, 'Blue', '200'),
Color(PdfColors.blue300, 'Blue', '300'),
Color(PdfColors.blue400, 'Blue', '400'),
Color(PdfColors.blue500, 'Blue', '500'),
Color(PdfColors.blue600, 'Blue', '600'),
Color(PdfColors.blue700, 'Blue', '700'),
Color(PdfColors.blue800, 'Blue', '800'),
Color(PdfColors.blue900, 'Blue', '900'),
Color(PdfColors.blueAccent100, 'Blue', 'Accent 100'),
Color(PdfColors.blueAccent200, 'Blue', 'Accent 200'),
Color(PdfColors.blueAccent400, 'Blue', 'Accent 400'),
Color(PdfColors.blueAccent700, 'Blue', 'Accent 700'),
]),
NewPage(),
Header(text: 'Light Blue'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.lightBlue50, 'Light Blue', '50'),
Color(PdfColors.lightBlue100, 'Light Blue', '100'),
Color(PdfColors.lightBlue200, 'Light Blue', '200'),
Color(PdfColors.lightBlue300, 'Light Blue', '300'),
Color(PdfColors.lightBlue400, 'Light Blue', '400'),
Color(PdfColors.lightBlue500, 'Light Blue', '500'),
Color(PdfColors.lightBlue600, 'Light Blue', '600'),
Color(PdfColors.lightBlue700, 'Light Blue', '700'),
Color(PdfColors.lightBlue800, 'Light Blue', '800'),
Color(PdfColors.lightBlue900, 'Light Blue', '900'),
Color(PdfColors.lightBlueAccent100, 'Light Blue',
'Accent 100'),
Color(PdfColors.lightBlueAccent200, 'Light Blue',
'Accent 200'),
Color(PdfColors.lightBlueAccent400, 'Light Blue',
'Accent 400'),
Color(PdfColors.lightBlueAccent700, 'Light Blue',
'Accent 700'),
]),
NewPage(),
Header(text: 'Cyan'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.cyan50, 'Cyan', '50'),
Color(PdfColors.cyan100, 'Cyan', '100'),
Color(PdfColors.cyan200, 'Cyan', '200'),
Color(PdfColors.cyan300, 'Cyan', '300'),
Color(PdfColors.cyan400, 'Cyan', '400'),
Color(PdfColors.cyan500, 'Cyan', '500'),
Color(PdfColors.cyan600, 'Cyan', '600'),
Color(PdfColors.cyan700, 'Cyan', '700'),
Color(PdfColors.cyan800, 'Cyan', '800'),
Color(PdfColors.cyan900, 'Cyan', '900'),
Color(PdfColors.cyanAccent100, 'Cyan', 'Accent 100'),
Color(PdfColors.cyanAccent200, 'Cyan', 'Accent 200'),
Color(PdfColors.cyanAccent400, 'Cyan', 'Accent 400'),
Color(PdfColors.cyanAccent700, 'Cyan', 'Accent 700'),
]),
NewPage(),
Header(text: 'Teal'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.teal50, 'Teal', '50'),
Color(PdfColors.teal100, 'Teal', '100'),
Color(PdfColors.teal200, 'Teal', '200'),
Color(PdfColors.teal300, 'Teal', '300'),
Color(PdfColors.teal400, 'Teal', '400'),
Color(PdfColors.teal500, 'Teal', '500'),
Color(PdfColors.teal600, 'Teal', '600'),
Color(PdfColors.teal700, 'Teal', '700'),
Color(PdfColors.teal800, 'Teal', '800'),
Color(PdfColors.teal900, 'Teal', '900'),
Color(PdfColors.tealAccent100, 'Teal', 'Accent 100'),
Color(PdfColors.tealAccent200, 'Teal', 'Accent 200'),
Color(PdfColors.tealAccent400, 'Teal', 'Accent 400'),
Color(PdfColors.tealAccent700, 'Teal', 'Accent 700'),
]),
NewPage(),
Header(text: 'Green'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.green50, 'Green', '50'),
Color(PdfColors.green100, 'Green', '100'),
Color(PdfColors.green200, 'Green', '200'),
Color(PdfColors.green300, 'Green', '300'),
Color(PdfColors.green400, 'Green', '400'),
Color(PdfColors.green500, 'Green', '500'),
Color(PdfColors.green600, 'Green', '600'),
Color(PdfColors.green700, 'Green', '700'),
Color(PdfColors.green800, 'Green', '800'),
Color(PdfColors.green900, 'Green', '900'),
Color(PdfColors.greenAccent100, 'Green', 'Accent 100'),
Color(PdfColors.greenAccent200, 'Green', 'Accent 200'),
Color(PdfColors.greenAccent400, 'Green', 'Accent 400'),
Color(PdfColors.greenAccent700, 'Green', 'Accent 700'),
]),
NewPage(),
Header(text: 'Light Green'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.lightGreen50, 'Light Green', '50'),
Color(PdfColors.lightGreen100, 'Light Green', '100'),
Color(PdfColors.lightGreen200, 'Light Green', '200'),
Color(PdfColors.lightGreen300, 'Light Green', '300'),
Color(PdfColors.lightGreen400, 'Light Green', '400'),
Color(PdfColors.lightGreen500, 'Light Green', '500'),
Color(PdfColors.lightGreen600, 'Light Green', '600'),
Color(PdfColors.lightGreen700, 'Light Green', '700'),
Color(PdfColors.lightGreen800, 'Light Green', '800'),
Color(PdfColors.lightGreen900, 'Light Green', '900'),
Color(PdfColors.lightGreenAccent100, 'Light Green',
'Accent100'),
Color(PdfColors.lightGreenAccent200, 'Light Green',
'Accent200'),
Color(PdfColors.lightGreenAccent400, 'Light Green',
'Accent400'),
Color(PdfColors.lightGreenAccent700, 'Light Green',
'Accent700'),
]),
NewPage(),
Header(text: 'Lime'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.lime50, 'Lime', '50'),
Color(PdfColors.lime100, 'Lime', '100'),
Color(PdfColors.lime200, 'Lime', '200'),
Color(PdfColors.lime300, 'Lime', '300'),
Color(PdfColors.lime400, 'Lime', '400'),
Color(PdfColors.lime500, 'Lime', '500'),
Color(PdfColors.lime600, 'Lime', '600'),
Color(PdfColors.lime700, 'Lime', '700'),
Color(PdfColors.lime800, 'Lime', '800'),
Color(PdfColors.lime900, 'Lime', '900'),
Color(PdfColors.limeAccent100, 'Lime', 'Accent 100'),
Color(PdfColors.limeAccent200, 'Lime', 'Accent 200'),
Color(PdfColors.limeAccent400, 'Lime', 'Accent 400'),
Color(PdfColors.limeAccent700, 'Lime', 'Accent 700'),
]),
NewPage(),
Header(text: 'Yellow'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.yellow50, 'Yellow', '50'),
Color(PdfColors.yellow100, 'Yellow', '100'),
Color(PdfColors.yellow200, 'Yellow', '200'),
Color(PdfColors.yellow300, 'Yellow', '300'),
Color(PdfColors.yellow400, 'Yellow', '400'),
Color(PdfColors.yellow500, 'Yellow', '500'),
Color(PdfColors.yellow600, 'Yellow', '600'),
Color(PdfColors.yellow700, 'Yellow', '700'),
Color(PdfColors.yellow800, 'Yellow', '800'),
Color(PdfColors.yellow900, 'Yellow', '900'),
Color(PdfColors.yellowAccent100, 'Yellow', 'Accent 100'),
Color(PdfColors.yellowAccent200, 'Yellow', 'Accent 200'),
Color(PdfColors.yellowAccent400, 'Yellow', 'Accent 400'),
Color(PdfColors.yellowAccent700, 'Yellow', 'Accent 700'),
]),
NewPage(),
Header(text: 'Amber'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.amber50, 'Amber', '50'),
Color(PdfColors.amber100, 'Amber', '100'),
Color(PdfColors.amber200, 'Amber', '200'),
Color(PdfColors.amber300, 'Amber', '300'),
Color(PdfColors.amber400, 'Amber', '400'),
Color(PdfColors.amber500, 'Amber', '500'),
Color(PdfColors.amber600, 'Amber', '600'),
Color(PdfColors.amber700, 'Amber', '700'),
Color(PdfColors.amber800, 'Amber', '800'),
Color(PdfColors.amber900, 'Amber', '900'),
Color(PdfColors.amberAccent100, 'Amber', 'Accent 100'),
Color(PdfColors.amberAccent200, 'Amber', 'Accent 200'),
Color(PdfColors.amberAccent400, 'Amber', 'Accent 400'),
Color(PdfColors.amberAccent700, 'Amber', 'Accent 700'),
]),
NewPage(),
Header(text: 'Orange'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.orange50, 'Orange', '50'),
Color(PdfColors.orange100, 'Orange', '100'),
Color(PdfColors.orange200, 'Orange', '200'),
Color(PdfColors.orange300, 'Orange', '300'),
Color(PdfColors.orange400, 'Orange', '400'),
Color(PdfColors.orange500, 'Orange', '500'),
Color(PdfColors.orange600, 'Orange', '600'),
Color(PdfColors.orange700, 'Orange', '700'),
Color(PdfColors.orange800, 'Orange', '800'),
Color(PdfColors.orange900, 'Orange', '900'),
Color(PdfColors.orangeAccent100, 'Orange', 'Accent 100'),
Color(PdfColors.orangeAccent200, 'Orange', 'Accent 200'),
Color(PdfColors.orangeAccent400, 'Orange', 'Accent 400'),
Color(PdfColors.orangeAccent700, 'Orange', 'Accent 700'),
]),
NewPage(),
Header(text: 'Deep Orange'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.deepOrange50, 'Deep Orange', '50'),
Color(PdfColors.deepOrange100, 'Deep Orange', '100'),
Color(PdfColors.deepOrange200, 'Deep Orange', '200'),
Color(PdfColors.deepOrange300, 'Deep Orange', '300'),
Color(PdfColors.deepOrange400, 'Deep Orange', '400'),
Color(PdfColors.deepOrange500, 'Deep Orange', '500'),
Color(PdfColors.deepOrange600, 'Deep Orange', '600'),
Color(PdfColors.deepOrange700, 'Deep Orange', '700'),
Color(PdfColors.deepOrange800, 'Deep Orange', '800'),
Color(PdfColors.deepOrange900, 'Deep Orange', '900'),
Color(PdfColors.deepOrangeAccent100, 'Deep Orange',
'Accent 100'),
Color(PdfColors.deepOrangeAccent200, 'Deep Orange',
'Accent 200'),
Color(PdfColors.deepOrangeAccent400, 'Deep Orange',
'Accent 400'),
Color(PdfColors.deepOrangeAccent700, 'Deep Orange',
'Accent 700'),
]),
NewPage(),
Header(text: 'Brown'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.brown50, 'Brown', '50'),
Color(PdfColors.brown100, 'Brown', '100'),
Color(PdfColors.brown200, 'Brown', '200'),
Color(PdfColors.brown300, 'Brown', '300'),
Color(PdfColors.brown400, 'Brown', '400'),
Color(PdfColors.brown500, 'Brown', '500'),
Color(PdfColors.brown600, 'Brown', '600'),
Color(PdfColors.brown700, 'Brown', '700'),
Color(PdfColors.brown800, 'Brown', '800'),
Color(PdfColors.brown900, 'Brown', '900'),
]),
NewPage(),
Header(text: 'Blue Grey'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.blueGrey50, 'Blue Grey', '50'),
Color(PdfColors.blueGrey100, 'Blue Grey', '100'),
Color(PdfColors.blueGrey200, 'Blue Grey', '200'),
Color(PdfColors.blueGrey300, 'Blue Grey', '300'),
Color(PdfColors.blueGrey400, 'Blue Grey', '400'),
Color(PdfColors.blueGrey500, 'Blue Grey', '500'),
Color(PdfColors.blueGrey600, 'Blue Grey', '600'),
Color(PdfColors.blueGrey700, 'Blue Grey', '700'),
Color(PdfColors.blueGrey800, 'Blue Grey', '800'),
Color(PdfColors.blueGrey900, 'Blue Grey', '900'),
]),
NewPage(),
Header(text: 'Grey'),
GridView(
crossAxisCount: 4,
direction: Axis.vertical,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
padding: const EdgeInsets.all(10),
children: <Widget>[
Color(PdfColors.white, 'White'),
Color(PdfColors.grey50, 'Grey', '50'),
Color(PdfColors.grey100, 'Grey', '100'),
Color(PdfColors.grey200, 'Grey', '200'),
Color(PdfColors.grey300, 'Grey', '300'),
Color(PdfColors.grey400, 'Grey', '400'),
Color(PdfColors.grey400, 'Grey', '400'),
Color(PdfColors.grey500, 'Grey', '500'),
Color(PdfColors.grey600, 'Grey', '600'),
Color(PdfColors.grey700, 'Grey', '700'),
Color(PdfColors.grey800, 'Grey', '800'),
Color(PdfColors.grey900, 'Grey', '900'),
Color(PdfColors.black, 'Black'),
]),
]));
final File file = File('colors.pdf');
file.writeAsBytesSync(pdf.save());
});
}
... ...
... ... @@ -38,22 +38,22 @@ void printMetrics(
canvas
..setLineWidth(0.5)
..drawRect(x, y + metrics.descent, metrics.advanceWidth, metrics.maxHeight)
..setStrokeColor(PdfColor.green)
..setStrokeColor(PdfColors.green)
..strokePath()
..drawRect(x + metrics.left, y + metrics.top, metrics.width, metrics.height)
..setStrokeColor(PdfColor.amber)
..setStrokeColor(PdfColors.amber)
..strokePath()
..drawLine(x + metrics.effectiveLeft - deb, y,
x + metrics.maxWidth + metrics.effectiveLeft + deb, y)
..setColor(PdfColor.blue)
..setColor(PdfColors.blue)
..strokePath()
..drawEllipse(x, y, 5, 5)
..setFillColor(PdfColor.black)
..setFillColor(PdfColors.black)
..fillPath()
..drawEllipse(x + metrics.advanceWidth, y, 5, 5)
..setFillColor(PdfColor.red)
..setFillColor(PdfColors.red)
..fillPath()
..setFillColor(PdfColor.grey)
..setFillColor(PdfColors.grey)
..drawString(font, fontSize, text, x, y);
}
... ...
... ... @@ -35,15 +35,15 @@ void printText(PdfGraphics canvas, String text, PdfFont font, double top) {
..setColor(const PdfColor(0.9, 0.9, 0.9))
..fillPath()
..drawLine(x + metrics.left - deb, y, x + metrics.right + deb, y)
..setColor(PdfColor.blue)
..setColor(PdfColors.blue)
..strokePath()
..drawLine(x + metrics.left - deb, y + metrics.ascent,
x + metrics.right + deb, y + metrics.ascent)
..setColor(PdfColor.green)
..setColor(PdfColors.green)
..strokePath()
..drawLine(x + metrics.left - deb, y + metrics.descent,
x + metrics.right + deb, y + metrics.descent)
..setColor(PdfColor.purple)
..setColor(PdfColors.purple)
..strokePath()
..setColor(const PdfColor(0.3, 0.3, 0.3))
..drawString(font, fontSize, text, x, y);
... ...
... ... @@ -34,15 +34,15 @@ void printText(PdfGraphics canvas, String text, PdfFont font, double top) {
..setColor(const PdfColor(0.9, 0.9, 0.9))
..fillPath()
..drawLine(x + metrics.left - deb, y, x + metrics.right + deb, y)
..setColor(PdfColor.blue)
..setColor(PdfColors.blue)
..strokePath()
..drawLine(x + metrics.left - deb, y + metrics.ascent,
x + metrics.right + deb, y + metrics.ascent)
..setColor(PdfColor.green)
..setColor(PdfColors.green)
..strokePath()
..drawLine(x + metrics.left - deb, y + metrics.descent,
x + metrics.right + deb, y + metrics.descent)
..setColor(PdfColor.purple)
..setColor(PdfColors.purple)
..strokePath()
..setColor(const PdfColor(0.3, 0.3, 0.3))
..drawString(font, fontSize, text, x, y);
... ...
... ... @@ -42,7 +42,7 @@ void main() {
padding: const EdgeInsets.all(5),
margin: const EdgeInsets.only(bottom: 10),
decoration: const BoxDecoration(
color: PdfColor.amber,
color: PdfColors.amber,
border: BoxBorder(
top: true,
bottom: true,
... ... @@ -149,7 +149,7 @@ void main() {
size: const PdfPoint(50, 50),
painter: (PdfGraphics canvas, PdfPoint size) {
canvas
..setColor(PdfColor.indigo)
..setColor(PdfColors.indigo)
..drawRRect(0, 0, size.x, size.y, 10, 10)
..fillPath();
})),
... ... @@ -166,7 +166,7 @@ void main() {
style: Theme.of(context)
.defaultTextStyleBold
.copyWith(
fontSize: 20, color: PdfColor.blue)),
fontSize: 20, color: PdfColors.blue)),
const TextSpan(
text: ' world!',
),
... ...