'How can i add watermark text over image in Flutter?
I am trying to add watermark text over the image. I am able to set Single text to image but i don't know how to repeat watermark text like below Image.
Code block:
Container(
child: ColorFiltered(
colorFilter:
ColorFilter.matrix(filters[index]),
child: Stack(children: [
Image.file(widget.editedImage,
filterQuality: FilterQuality.high),
Positioned(
top: yPosition,
left: xPosition,
child: GestureDetector(
onPanUpdate: (tapInfo) {
setState(() {
xPosition += tapInfo.delta.dx;
yPosition += tapInfo.delta.dy;
});
},
child: Container(
alignment: Alignment.center,
child: Text(
'Confidential',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.grey[600])),
),),)
])),
),
),
);
Solution 1:[1]
The best solution is to make those 'confidential' watermark text as an image and place it as background using stack.
Solution 2:[2]
Here is your solution,
return Stack(
children: [
Material(
child: Container(
color: Colors.white,
child: SingleChildScrollView(
child: Column(
children: [
for(var i=0;i<=10;i++)
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
for(var i=0;i<=5;i++)
Padding(
padding: EdgeInsets.symmetric(vertical: 50 ,horizontal: 20),
child: Transform.rotate(
angle: -51,
child: Text('CONFIDENTIAL', style: TextStyle(fontSize: 16, color: Colors.grey),),
),
)
],
),
)
],
),
),
),
),
Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.black.withOpacity(0.6),
elevation: 0,
),
body: Center(
child: Text('Welcome', style: Theme.of(context).textTheme.headline2,),
),
),
],
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Genius_balu |
| Solution 2 | Genius_balu |

