在Flutter中绘制并与SVG交互

在Flutter中绘制并与SVG交互,第1张

在Flutter中绘制并与SVG交互

我使用

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



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4979815.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-14

发表评论

登录后才能评论

评论列表(0条)

    保存