Fix: null labelPainter
This commit is contained in:
parent
ae85badc74
commit
5c371cf6fc
@ -243,7 +243,7 @@ class AnimatedCircularChartState extends State<AnimatedCircularChart>
|
|||||||
size: widget.size,
|
size: widget.size,
|
||||||
painter: new AnimatedCircularChartPainter(
|
painter: new AnimatedCircularChartPainter(
|
||||||
_tween.animate(_animation),
|
_tween.animate(_animation),
|
||||||
_labelPainter,
|
widget.holeLabel != null ? _labelPainter : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,7 @@ class AnimatedCircularChartPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
labelPainter.paint(
|
_paintLabel(canvas, size, labelPainter);
|
||||||
canvas,
|
|
||||||
new Offset(
|
|
||||||
size.width / 2 - labelPainter.width / 2,
|
|
||||||
size.height / 2 - labelPainter.height / 2,
|
|
||||||
));
|
|
||||||
_paintChart(canvas, size, animation.value);
|
_paintChart(canvas, size, animation.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,12 +30,7 @@ class CircularChartPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
labelPainter.paint(
|
_paintLabel(canvas, size, labelPainter);
|
||||||
canvas,
|
|
||||||
new Offset(
|
|
||||||
size.width / 2 - labelPainter.width / 2,
|
|
||||||
size.height / 2 - labelPainter.height / 2,
|
|
||||||
));
|
|
||||||
_paintChart(canvas, size, chart);
|
_paintChart(canvas, size, chart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +40,18 @@ class CircularChartPainter extends CustomPainter {
|
|||||||
|
|
||||||
const double _kRadiansPerDegree = Math.pi / 180;
|
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) {
|
void _paintChart(Canvas canvas, Size size, CircularChart chart) {
|
||||||
final Paint segmentPaint = new Paint()
|
final Paint segmentPaint = new Paint()
|
||||||
..style = chart.chartType == CircularChartType.Radial
|
..style = chart.chartType == CircularChartType.Radial
|
||||||
|
Loading…
Reference in New Issue
Block a user