我想画一个六边形,但我不能做我想做的。 这是我的结果:
Path createHexagonPath() {
const int SIDES_OF_HEXAGON = 6;
const double radius = 50;
const Offset center = Offset(50, 50);
final path = Path();
var angle = (pi * 2) / SIDES_OF_HEXAGON;
Offset firstPoint = Offset(radius * cos(0.0), radius * sin(0.0));
path.moveTo(firstPoint.dx + center.dx, firstPoint.dy + center.dy);
for (int i = 1; i <= SIDES_OF_HEXAGON; i++) {
double x = radius * cos(angle * i) + center.dx;
double y = radius * sin(angle * i) + center.dy;
path.lineTo(x, y);
}
path.close();
return path;
}
我希望是这样:
答案 0 :(得分:1)
转到这个网站https://fluttershapemaker.com它简单易行
答案 1 :(得分:0)
你可以试试这个,polygon_clipper 和 flutter_neumorphic
Neumorphic(
style: NeumorphicStyle(
depth: -5,
lightSource: LightSource.topLeft,
color: Colors.grey
),
child:
ClipPolygon(
sides: 6,
borderRadius: 5.0, // Default 0.0 degrees
rotate: 90.0, // Default 0.0 degrees
boxShadows: [
PolygonBoxShadow(color: Colors.black, elevation: 1.0),
PolygonBoxShadow(color: Colors.grey, elevation: 5.0)
],
child: Container(color: Colors.black),
),
)