'Is it possible to provide drop shadow to an PNG Image in flutter?
Solution 1:[1]
You can achieve it from using Stack, BackdropFilter and duplicating image twice.
Stack(
children: [
Image.asset(
imgPath,
color: Colors.black.withOpacity(0.7),
),
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 10.0,
sigmaY: 10.0,
),
child: Image.asset(
imgPath,
),
)
],
),
The first image will act as the shadow. You can adjust effect by changing the transparency value and sigma values
Solution 2:[2]
Try using the following code.
Stack(
alignment: Alignment.center,
children: [
Image.asset(
imgPath,
color: Colors.black.withOpacity(0.3),
),
ClipRect(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 5.0,
sigmaY: 5.0,
),
child: Image.asset(
imgPath,
),
),
),
)
],
)
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 | dewmina udayashan |
Solution 2 | Aritra Choudhury |