simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
+9 -16
View File
@@ -152,22 +152,15 @@ class _PmRichTextState extends State<PmRichText> {
double? _fontSize(dynamic raw, double base) {
if (raw is! String) return null;
final match = RegExp(r'^(\d+(?:\.\d+)?)(px|rem|em|%)$').firstMatch(raw);
if (match == null) return null;
final value = double.parse(match.group(1)!);
final double size;
switch (match.group(2)) {
case 'px':
size = value;
case 'rem':
size = value * 16;
case 'em':
size = base * value;
case '%':
size = base * value / 100;
default:
return null;
}
final length = parsePmCssLength(raw);
if (length == null) return null;
final value = length.value;
final size = switch (length.unit) {
'px' => value,
'rem' => value * 16,
'em' => base * value,
_ => base * value / 100,
};
return size.clamp(8, 72);
}