dart_pkpass/lib/pkpass/utils/mabe_decode.dart
The one with the braid 6e7f19a764 feat: implement web service
Signed-off-by: The one with the braid <info@braid.business>
2023-11-26 19:42:29 +01:00

29 lines
757 B
Dart

import '../models/pass_structure_dictionary.dart';
import 'color_helper.dart';
abstract class MaybeDecode {
const MaybeDecode._();
static int? maybeColor(String? colorCode) {
if (colorCode == null) return null;
return fromCssColor(colorCode);
}
static DateTime? maybeDateTime(String? timeStamp) {
if (timeStamp == null) return null;
return DateTime.tryParse(timeStamp);
}
static PassTextAlign? maybeTextAlign(String? align) {
switch (align) {
case 'PKTextAlignmentLeft':
return PassTextAlign.left;
case 'PKTextAlignmentCenter':
return PassTextAlign.center;
case 'PKTextAlignmentRight':
return PassTextAlign.right;
default:
return PassTextAlign.natural;
}
}
}