CheckoutAction.fromJson constructor
Parses and validates a required action from the native bridge.
Implementation
factory CheckoutAction.fromJson(Map<Object?, Object?> value) {
_expectFields(value, const {'type', 'expiresAt'});
final rawType = value['type'];
final rawExpiresAt = value['expiresAt'];
final type = rawType is String
? CheckoutActionType.fromWireValue(rawType)
: null;
final expiresAt = rawExpiresAt == null
? null
: rawExpiresAt is String
? DateTime.tryParse(rawExpiresAt)
: null;
if (type == null || (rawExpiresAt != null && expiresAt == null)) {
throw const FormatException('Invalid Checkout action');
}
return CheckoutAction(type: type, expiresAt: expiresAt);
}