Created
December 30, 2020 10:01
-
-
Save milomai/c618eae95368493229ea2b97af0656c4 to your computer and use it in GitHub Desktop.
Draw mask with hollow (transparent hole inside)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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