Skip to content

Instantly share code, notes, and snippets.

View juskek's full-sized avatar

Justin juskek

View GitHub Profile
@juskek
juskek / flutter_radar_chart_animated.dart
Last active August 18, 2021 19:18
Code used to implement animations into CustomPainter.
class RadarChartTransition extends AnimatedWidget {
final AnimationController controller;
final int nodes;
final int segments;
final List<double> data;
final List<String> labels;
// CONSTRUCTOR
RadarChartTransition(
this.controller,
@juskek
juskek / flutter_radar_chart_drawing.dart
Last active August 18, 2021 11:10
How the radar chart is drawn in CustomPainter.
void paint(ui.Canvas canvas, ui.Size size) {
final Offset centerPoint = Offset(0, 0);
// math for each branch
final angle = 360 / nodes;
// list of branch end points (x,y)
List<List<double>> points = [];
// for each branch
for (int i = 0; i < nodes; i++) {
final double lineLength = 200;
@juskek
juskek / flutter_radar_chart_codeStructure.dart
Last active August 18, 2021 09:09
Code structure for flutter_radar_chart.
class MyApp extends StatelessWidget {
...
Widget build(...) {
return MaterialApp(..., home: MyHomePage());
}
}
class MyHomePage extends StatefulWidget {
...
_MyHomePageState createState() => _MyHomePageState();