0

I am unable to achieve this effect in Flutter web (rendered as HTML), whereby the requirement is to have a transparent container (card or otherwise) with an offset shadow:

Transparent button with shadow

Current code:

   Container(
        decoration: BoxDecoration(
          color: Colors.transparent,
          borderRadius: BorderRadius.circular(myBtnRadius),
          boxShadow: [
            CustomBoxShadow(
              color: Colors.black87.withOpacity(myBtnShadowOpacity),
              blurRadius: 4,
              blurStyle: BlurStyle.outer,
              spreadRadius: -2,
              offset: const Offset(3, 5),
            ),
          ],
        ),
        child: ClipPath(
            clipper: ShapeBorderClipper(
                shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(myBtnRadius)))),
            child: _buildMyCard()),
      ),

CustomBoxShadow derived from code here

_buildMyCard just returns a Card widget with elevation set to 0 and color transparent.

Best result I can achieve is this:

enter image description here

Any ideas? Do I need to get more creative with some clipping / mask?

CoastalB
  • 695
  • 4
  • 15

1 Answers1

0

Ultimately, when rendering a Flutter web app as HTML, the only way I could achieve this effect was to use a Stack widget with an html.DivElement using style.BoxShadow to create the shadow with cut-out effect.

CoastalB
  • 695
  • 4
  • 15