Skip to content

Instantly share code, notes, and snippets.

@juskek
Last active August 18, 2021 09:09
Show Gist options
  • Save juskek/b5026ac74765451cb564d61b8cbc73ec to your computer and use it in GitHub Desktop.
Save juskek/b5026ac74765451cb564d61b8cbc73ec to your computer and use it in GitHub Desktop.
Code structure for flutter_radar_chart.
class MyApp extends StatelessWidget {
...
Widget build(...) {
return MaterialApp(..., home: MyHomePage());
}
}
class MyHomePage extends StatefulWidget {
...
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
...
late final AnimationController _controller = AnimationController(...).forward();
...
Widget build(...) {
return Scaffold(..., child: RadarChartTransition(...));
}
}
class RadarChartTransition extends AnimatedWidget {
Widget build(...) {
return CustomPaint(painter: RadarChartPainter(...));
}
}
class RadarChartPainter extends CustomPainter {
...
void paint(...) {
... // custom paint commands
}
@override
bool shouldRepaint(...) {
return true; // repaint whenever CustomPainter is rebuilt
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment