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
+8 -13
View File
@@ -123,19 +123,14 @@ class PmImageView extends StatelessWidget {
double? _resolveWidth(String? width, double available) {
if (width == null) return null;
final match = RegExp(r'^(\d+(?:\.\d+)?)(px|%|em|rem)$').firstMatch(width);
if (match == null) return null;
final value = double.parse(match.group(1)!);
final double resolved;
switch (match.group(2)) {
case '%':
resolved = available * value / 100;
case 'em':
case 'rem':
resolved = value * 16;
default:
resolved = value;
}
final length = parsePmCssLength(width);
if (length == null) return null;
final value = length.value;
final resolved = switch (length.unit) {
'%' => available * value / 100,
'em' || 'rem' => value * 16,
_ => value,
};
return resolved.clamp(1, available);
}
}