centerContentBounds property
Gets a bounding box for the largest center content card that can fit inside the hole of the chart.
If the inner radius of the arcs is smaller than
ArcRendererConfig.minHoleWidthForCenterContent
, this will return a
rectangle of 0 width and height to indicate that no card can fit inside
the chart.
Implementation
Rectangle<int> get centerContentBounds {
// Grab the first arcList from the animated set.
final arcLists = getArcLists();
final arcList = arcLists.isNotEmpty ? arcLists.first : null;
// No card should be visible if the hole in the chart is too small.
if (arcList == null ||
arcList.innerRadius! < config.minHoleWidthForCenterContent) {
// Return default bounds of 0 size.
final bounds = chart!.drawAreaBounds;
return Rectangle<int>(
(bounds.left + bounds.width / 2).round(),
(bounds.top + bounds.height / 2).round(),
0,
0,
);
}
// Fix the height and width of the center content div to the maximum box
// size that will fit within the pie's inner radius.
final width = (_cosPIOver4 * arcList.innerRadius!).floor();
return Rectangle<int>(
(arcList.center!.x - width).round(),
(arcList.center!.y - width).round(),
width * 2,
width * 2,
);
}