David PHAM-VAN

Add Watermark widget

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ## 1.3.20 3 ## 1.3.20
4 4
5 - Fix Transform.rotateBox 5 - Fix Transform.rotateBox
  6 +- Add Watermark widget
6 7
7 ## 1.3.19 8 ## 1.3.19
8 9
@@ -181,3 +181,48 @@ class Bullet extends StatelessWidget { @@ -181,3 +181,48 @@ class Bullet extends StatelessWidget {
181 ])); 181 ]));
182 } 182 }
183 } 183 }
  184 +
  185 +class Watermark extends StatelessWidget {
  186 + Watermark({
  187 + @required this.child,
  188 + this.fit = BoxFit.contain,
  189 + this.angle = 0,
  190 + }) : assert(fit != null),
  191 + assert(child != null),
  192 + assert(angle != null);
  193 +
  194 + Watermark.text(
  195 + String text, {
  196 + TextStyle style,
  197 + this.fit = BoxFit.contain,
  198 + this.angle = math.pi / 4,
  199 + }) : assert(fit != null),
  200 + assert(angle != null),
  201 + child = Text(
  202 + text,
  203 + style: style ??
  204 + TextStyle(
  205 + color: PdfColors.grey200,
  206 + fontWeight: FontWeight.bold,
  207 + ),
  208 + );
  209 +
  210 + final Widget child;
  211 +
  212 + final double angle;
  213 +
  214 + final BoxFit fit;
  215 +
  216 + @override
  217 + Widget build(Context context) {
  218 + return SizedBox.expand(
  219 + child: FittedBox(
  220 + fit: fit,
  221 + child: Transform.rotateBox(
  222 + angle: angle,
  223 + child: child,
  224 + ),
  225 + ),
  226 + );
  227 + }
  228 +}