
我使用
built_path库将其工作,该库将
SVG路径预编译为
Path对象。然后,将其包装到
ClipPathWidget中,如下所示:
return GestureDetector( onTap: () => _bodyPartTapped(part), child: ClipPath( child: Stack(children: <Widget>[ Container( color: pressedBodyPart == part ? Colors.blue : Colors.transparent), CustomPaint(painter: PathPainter(path)) ]), clipper: PathClipper(path)));
如果按下该按钮,它将使身体部位着色为蓝色,效果很好。
我创建了一个完整的示例,可以在这里找到:
https://github.com/gi097/flutter_clickable_regions
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)