Last active
January 13, 2023 18:06
-
-
Save TechieBlossom/533bb8ef74f22bd6ea68a5d0dc9866bc to your computer and use it in GitHub Desktop.
ClipPath and CustomClipper
This file contains 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
ClipPath( | |
clipper: HexagonClipper(radius: radius), | |
child: SizedBox( | |
width: diameter, | |
height: diameter, | |
child: ColoredBox( | |
color: Colors.blueAccent.withOpacity(0.7), | |
), | |
), | |
) | |
class HexagonClipper extends CustomClipper<Path> { | |
const HexagonClipper({ | |
required this.radius, | |
}); | |
final double radius; | |
@override | |
Path getClip(Size size) { | |
final center = Offset(size.width / 2, size.width / 2); | |
Path path = Path(); | |
path.addPolygon( | |
Offset(x, y), | |
... | |
... | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment