parseFontSize function
Implementation
double parseFontSize(dynamic input) {
if (input is num) {
return input.toDouble();
} else if (input is String) {
if (input == "") return 12;
if (input.contains("px")) input = input.replaceAll("px", "");
// Try to extract the numeric value from the string
RegExp regex = RegExp(r'(\d+(\.\d+)?)');
var match = regex.firstMatch(input);
if (match != null) {
return double.parse(match.group(0)!);
}
}
return 12;
}