Fix: null labelPainter

This commit is contained in:
Victor Choueiri authored and Victor Choueiri committed 2018-03-21 03:55:55 +02:00
1 parent ae85badc74
commit 5c371cf6fc
2 files changed
+15 -13

No files matched your search

+1 -1
View File
@@ -243,7 +243,7 @@ class AnimatedCircularChartState extends State<AnimatedCircularChart>
size: widget.size,
painter: new AnimatedCircularChartPainter(
_tween.animate(_animation),
_labelPainter,
widget.holeLabel != null ? _labelPainter : null,
),
);
}
+14 -12
View File
@@ -14,12 +14,7 @@ class AnimatedCircularChartPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
labelPainter.paint(
canvas,
new Offset(
size.width / 2 - labelPainter.width / 2,
size.height / 2 - labelPainter.height / 2,
));
_paintLabel(canvas, size, labelPainter);
_paintChart(canvas, size, animation.value);
}
@@ -35,12 +30,7 @@ class CircularChartPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
labelPainter.paint(
canvas,
new Offset(
size.width / 2 - labelPainter.width / 2,
size.height / 2 - labelPainter.height / 2,
));
_paintLabel(canvas, size, labelPainter);
_paintChart(canvas, size, chart);
}
@@ -50,6 +40,18 @@ class CircularChartPainter extends CustomPainter {
const double _kRadiansPerDegree = Math.pi / 180;
void _paintLabel(Canvas canvas, Size size, TextPainter labelPainter) {
if (labelPainter != null) {
labelPainter.paint(
canvas,
new Offset(
size.width / 2 - labelPainter.width / 2,
size.height / 2 - labelPainter.height / 2,
),
);
}
}
void _paintChart(Canvas canvas, Size size, CircularChart chart) {
final Paint segmentPaint = new Paint()
..style = chart.chartType == CircularChartType.Radial