首页 > 解决方案 > 如何实现交互式复杂形状?

问题描述

我需要操纵曲线(例如:悬停颜色变化),但是使用 MouseRegion 和 CustomPaint 我只能与一块矩形进行交互,操纵曲线不够精确。

就像那样,我希望鼠标在曲线上移动并做一些事情,比如改变颜色或设置一些业务属性。

图片

这是我当前的代码:

return Positioned(
      top: dy,
      left: dx,
      width: 300,
      height: 50,
      child: ColoredBox(
        color: Colors.blue.withOpacity(0.3),
        child: SizedBox(
          width: 250.0,
          height: 250.0,
          child: MouseRegion(
            cursor: _cursor,
            onEnter: _onEnter,
            onExit: _onExit,
            child: CustomPaint(
              painter: CurvePainter(color: _color),
              child: Container(),
            ),
          ),
        ),
      ),
    );

标签: flutterflutter-desktop

解决方案


推荐阅读