getMaximumEntryWidth method
returns the maximum length in pixels across all legend labels + formsize
- formtotextspace
@param p the paint object used for rendering the text @return
Implementation
double getMaximumEntryWidth(TextPainter? p) {
double max = 0;
double maxFormSize = 0;
double? formToTextSpace = Utils.convertDpToPixel(_formToTextSpace);
for (LegendEntry? entry in _entries) {
final double formSize = Utils.convertDpToPixel(
double.nan == entry!.formSize ? _formSize : entry.formSize);
if (formSize > maxFormSize) maxFormSize = formSize;
String? label = entry.label;
if (label == null) continue;
double length = Utils.calcTextWidth(p!, label).toDouble();
if (length > max) max = length;
}
return max + maxFormSize + formToTextSpace;
}