Skip to content

Instantly share code, notes, and snippets.

@milomai
Created December 30, 2020 10:01
Show Gist options
  • Select an option

  • Save milomai/c618eae95368493229ea2b97af0656c4 to your computer and use it in GitHub Desktop.

Select an option

Save milomai/c618eae95368493229ea2b97af0656c4 to your computer and use it in GitHub Desktop.
Draw mask with hollow (transparent hole inside)
var maskColor = Colors.black.withOpacity(0.4);
ColorFiltered(
colorFilter: ColorFilter.mode(maskColor,
BlendMode.srcOut), // This mean: the child's opacity part will be transparent, but the transparent will render with maskColor
child: Container(
color: Colors.transparent,
child: Center( // Any shape you like, but make sure the widget is opacity
child: Container(
width: 200,
height: 200,
color: Colors.black,
),
),
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment