Flutter之CustomPainter时钟绘制
无意间在网上看到下图的绘制效果,便想着画一个时钟,正好学习一下,先上图。 环形圆 时钟 请大家忽略那个可恶的数字“0”。。。 环形圆关键代码 @override void paint ( Canvas canvas , Size size ) { int n = 20 ; var range = List <int> . generate ( n , ( i ) => i + 1 ); for ( int i in range ) { double x = 2 * math . pi / n ; double dx = radius * math . sin ( i * x ); double dy = radius * math . cos ( i * x ); print ( "dx${i.toString()}=>${dx.toString()}" ); print ( "dy${i.toString()}=>${dy.toString()}" ); canvas . drawCircle ( Offset ( dx , dy ), radius , myPaint ); } } 时钟完整代码 class TimeClockWidget extends StatefulWidget { @override _TimeClockWidgetState createState (