Fix: null labelPainter
This commit is contained in:
parent
ae85badc74
commit
5c371cf6fc
@ -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 +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
|
||||
|
Loading…
Reference in New Issue
Block a user