addWaterMarkTextSync method
Image
addWaterMarkTextSync(
- String text, {
- WMLocation location = WMLocation.tile,
- TextStyle style = const TextStyle(),
- TextDirection textDirection = TextDirection.ltr,
- int? maxLines,
- double? minWidth,
- double? maxWidth,
- double opacity = 0.3,
- double sizeScale = 1,
- double vOffset = 20,
- double hOffset = 20,
- double angle = 0,
- bool isDispose = false,
Image Watermark Extension
Implementation
Image addWaterMarkTextSync(
String text, {
WMLocation location = WMLocation.tile,
TextStyle style = const TextStyle(),
TextDirection textDirection = TextDirection.ltr,
int? maxLines,
double? minWidth,
double? maxWidth,
double opacity = 0.3,
double sizeScale = 1,
double vOffset = 20,
double hOffset = 20,
double angle = 0,
bool isDispose = false,
}) {
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder, rect());
canvas.drawImage(this, Offset.zero, Paint());
final Image tImage = _textPaint(
text,
style,
textDirection: textDirection,
minWidth: minWidth ?? 0,
maxWidth: maxWidth ?? double.infinity,
maxLines: maxLines ?? 6,
);
_watermakrLayer(
canvas, tImage, location, opacity, sizeScale, vOffset, hOffset, angle);
final Picture picture = recorder.endRecording();
if (isDispose) dispose();
tImage.dispose();
return picture.toImageSync(width, height);
}